From 348a4651b42d5ff64fd07e36ef9ca7d7e76f4277 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sat, 27 Aug 2022 12:25:38 -0500 Subject: [PATCH] feat: Bump ts-poet for dprint, also use tsx (#660) * feat: Bump ts-poet for dprint. * Use tsx instead of ts-node. * Use preferSingleLine. --- .github/workflows/lint.yml | 2 +- .prettierrc | 6 +- integration/angular/simple-message.ts | 22 +- integration/async-iterable-services/simple.ts | 42 +- .../simple.ts | 4 +- .../simple2.ts | 2 +- integration/avoid-import-conflicts/simple.ts | 67 +- integration/avoid-import-conflicts/simple2.ts | 61 +- integration/barrel-imports/bar.ts | 27 +- integration/barrel-imports/foo.ts | 28 +- integration/batching-with-context/batching.ts | 162 +- integration/batching/batching.ts | 109 +- integration/bytes-as-base64/message.ts | 44 +- .../bytes-node/google/protobuf/wrappers.ts | 88 +- integration/bytes-node/point.ts | 44 +- integration/codegen.sh | 2 +- integration/codegen.ts | 24 +- integration/const-enum/const-enum.ts | 66 +- .../enums-as-literals-with-string-enums.ts | 52 +- .../enums-as-literals/enums-as-literals.ts | 50 +- integration/fieldmask/fieldmask.ts | 24 +- .../fieldmask/google/protobuf/field_mask.ts | 32 +- integration/file-suffix/child.pb.ts | 40 +- .../google/protobuf/timestamp.pb.ts | 42 +- integration/file-suffix/parent.pb.ts | 26 +- integration/generic-metadata/hero.ts | 70 +- .../simple.ts | 54 +- .../generic-service-definitions/simple.ts | 54 +- integration/global-this/global-this.ts | 38 +- integration/grpc-js/google/protobuf/empty.ts | 21 +- integration/grpc-js/google/protobuf/struct.ts | 83 +- .../grpc-js/google/protobuf/timestamp.ts | 42 +- .../grpc-js/google/protobuf/wrappers.ts | 88 +- integration/grpc-js/simple.ts | 236 +- integration/grpc-web-go-server/example.ts | 174 +- .../example.ts | 107 +- integration/grpc-web-no-streaming/example.ts | 103 +- integration/grpc-web/example.ts | 220 +- integration/import-suffix/child.pb.ts | 40 +- .../google/protobuf/timestamp.pb.ts | 42 +- integration/import-suffix/parent.pb.ts | 26 +- integration/lower-case-svc-methods/math.ts | 54 +- .../meta-typings/google/protobuf/timestamp.ts | 237 +- .../meta-typings/google/protobuf/wrappers.ts | 829 ++- integration/meta-typings/google/type/date.ts | 251 +- integration/meta-typings/import_dir/thing.ts | 100 +- integration/meta-typings/simple.ts | 2870 ++++---- integration/nestjs-metadata-grpc-js/hero.ts | 20 +- .../nestjs-metadata-observables/hero.ts | 20 +- .../nestjs-metadata-restparameters/hero.ts | 20 +- integration/nestjs-metadata/hero.ts | 20 +- integration/nestjs-restparameters/hero.ts | 18 +- integration/nestjs-simple-observables/hero.ts | 18 +- .../google/protobuf/empty.ts | 7 +- .../nestjs-simple-restparameters/hero.ts | 18 +- .../nestjs-simple/google/protobuf/empty.ts | 7 +- .../google/protobuf/timestamp.ts | 6 +- integration/nestjs-simple/hero.ts | 22 +- .../nice-grpc/google/protobuf/empty.ts | 18 +- .../nice-grpc/google/protobuf/struct.ts | 80 +- .../nice-grpc/google/protobuf/timestamp.ts | 39 +- .../nice-grpc/google/protobuf/wrappers.ts | 85 +- integration/nice-grpc/simple.ts | 121 +- .../no-proto-package/no-proto-package.ts | 37 +- integration/oneof-properties/oneof.ts | 91 +- .../google/protobuf/struct.ts | 180 +- integration/oneof-unions-snake/simple.ts | 29 +- .../oneof-unions/google/protobuf/struct.ts | 174 +- integration/oneof-unions/oneof.ts | 221 +- .../only-types-grpc-metadata.ts | 4 +- integration/only-types/google/protobuf/any.ts | 3 +- .../only-types/google/protobuf/timestamp.ts | 4 +- integration/only-types/reservation.ts | 4 +- .../options/google/protobuf/descriptor.ts | 6102 ++++++++--------- integration/options/options.ts | 606 +- integration/options/something/something.ts | 155 +- integration/point/point.ts | 27 +- integration/reserved-words/reserved-words.ts | 21 +- integration/return-observable/observable.ts | 40 +- .../simple-deprecated-fields/simple.ts | 54 +- integration/simple-esmodule-interop/simple.ts | 51 +- .../google/protobuf/timestamp.ts | 42 +- integration/simple-json-name/simple.ts | 72 +- .../google/protobuf/timestamp.ts | 30 +- .../google/protobuf/wrappers.ts | 98 +- integration/simple-long-string/simple.ts | 66 +- .../simple-long/google/protobuf/wrappers.ts | 93 +- integration/simple-long/simple.ts | 110 +- .../google/protobuf/timestamp.ts | 42 +- .../google/protobuf/wrappers.ts | 88 +- .../simple-optionals/import_dir/thing.ts | 26 +- integration/simple-optionals/simple.ts | 257 +- integration/simple-optionals/thing.ts | 26 +- integration/simple-proto2/simple.ts | 34 +- .../google/protobuf/timestamp.ts | 42 +- .../google/protobuf/wrappers.ts | 88 +- .../google/type/date.ts | 18 +- .../import_dir/thing.ts | 26 +- .../simple-prototype-defaults/simple.ts | 398 +- .../simple-snake/google/protobuf/struct.ts | 83 +- .../simple-snake/google/protobuf/timestamp.ts | 42 +- .../simple-snake/google/protobuf/wrappers.ts | 88 +- integration/simple-snake/import_dir/thing.ts | 26 +- integration/simple-snake/simple.ts | 263 +- .../google/protobuf/struct.ts | 87 +- integration/simple-string-enums/simple.ts | 70 +- .../google/protobuf/timestamp.ts | 42 +- .../google/protobuf/wrappers.ts | 88 +- .../import_dir/thing.ts | 26 +- .../simple-unrecognized-enum/simple.ts | 257 +- .../simple/google/protobuf/timestamp.ts | 42 +- .../simple/google/protobuf/wrappers.ts | 88 +- integration/simple/google/type/date.ts | 18 +- integration/simple/import_dir/thing.ts | 26 +- integration/simple/simple.ts | 386 +- integration/struct/google/protobuf/struct.ts | 83 +- integration/struct/struct.ts | 26 +- integration/type-registry/bar/bar.ts | 37 +- integration/type-registry/foo.ts | 65 +- .../type-registry/google/protobuf/struct.ts | 111 +- .../google/protobuf/timestamp.ts | 52 +- integration/type-registry/typeRegistry.ts | 15 +- integration/types-with-underscores/file.ts | 27 +- .../google/protobuf/compiler/plugin.ts | 80 +- .../google/protobuf/descriptor.ts | 389 +- integration/unknown-fields/options.ts | 36 +- .../unknown-fields/something/something.ts | 16 +- .../google/protobuf/timestamp.ts | 42 +- integration/use-date-false/metadata.ts | 33 +- .../google/protobuf/timestamp.ts | 42 +- .../use-date-string/use-date-string.ts | 46 +- .../use-date-true/google/protobuf/empty.ts | 21 +- .../google/protobuf/timestamp.ts | 42 +- integration/use-date-true/use-date-true.ts | 58 +- integration/use-exact-types-false/foo.ts | 30 +- .../google/protobuf/duration.ts | 2 +- .../google/protobuf/field_mask.ts | 3 +- .../google/protobuf/timestamp.ts | 4 +- .../use-json-wire-format.ts | 2 +- .../google/protobuf/struct.ts | 79 +- integration/use-numeric-enum-json/simple.ts | 54 +- .../objectid/objectid.ts | 28 +- .../use-objectid-true.ts | 64 +- integration/use-optionals-all/test.ts | 109 +- integration/value/google/protobuf/struct.ts | 83 +- integration/value/google/protobuf/wrappers.ts | 88 +- integration/value/value.ts | 24 +- integration/vector-tile/vector_tile.ts | 86 +- integration/watch.ts | 84 +- package.json | 10 +- src/case.ts | 12 +- src/context.ts | 6 +- src/encode.ts | 52 +- src/enums.ts | 36 +- src/generate-async-iterable.ts | 2 +- src/generate-generic-service-definition.ts | 18 +- src/generate-grpc-js.ts | 58 +- src/generate-grpc-web.ts | 32 +- src/generate-nestjs.ts | 48 +- src/generate-nice-grpc.ts | 24 +- src/generate-services.ts | 68 +- src/generate-type-registry.ts | 14 +- src/main.ts | 244 +- src/options.ts | 70 +- src/plugin.ts | 20 +- src/schema.ts | 106 +- src/sourceInfo.ts | 8 +- src/types.ts | 158 +- src/utils.ts | 44 +- src/visit.ts | 20 +- tests/case-test.ts | 60 +- tests/options-test.ts | 72 +- tests/types-test.ts | 50 +- tests/utils-test.ts | 28 +- yarn.lock | 295 +- 175 files changed, 10279 insertions(+), 11552 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7af321c34..67377b7d3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,6 +23,6 @@ jobs: - name: install dependencies run: yarn install || echo "ignore failure" - name: Prettier - run: yarn prettier:check + run: yarn format:check env: CI: true diff --git a/.prettierrc b/.prettierrc index 5c9307832..963354f23 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,3 @@ { - "printWidth": 120, - "bracketSpacing": true, - "singleQuote": true -} \ No newline at end of file + "printWidth": 120 +} diff --git a/integration/angular/simple-message.ts b/integration/angular/simple-message.ts index 44b1c146b..0457ee8a8 100644 --- a/integration/angular/simple-message.ts +++ b/integration/angular/simple-message.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'angular'; +export const protobufPackage = "angular"; export interface SimpleMessage { numberField: number; @@ -38,9 +38,7 @@ export const SimpleMessage = { }, fromJSON(object: any): SimpleMessage { - return { - numberField: isSet(object.numberField) ? Number(object.numberField) : 0, - }; + return { numberField: isSet(object.numberField) ? Number(object.numberField) : 0 }; }, toJSON(message: SimpleMessage): unknown { @@ -58,19 +56,13 @@ export const SimpleMessage = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/async-iterable-services/simple.ts b/integration/async-iterable-services/simple.ts index b5a62a9a9..6b478bce1 100644 --- a/integration/async-iterable-services/simple.ts +++ b/integration/async-iterable-services/simple.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; /** EchoMsg is the message body for Echo. */ export interface EchoMsg { @@ -9,12 +9,12 @@ export interface EchoMsg { } function createBaseEchoMsg(): EchoMsg { - return { body: '' }; + return { body: "" }; } export const EchoMsg = { encode(message: EchoMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.body !== '') { + if (message.body !== "") { writer.uint32(10).string(message.body); } return writer; @@ -41,7 +41,7 @@ export const EchoMsg = { // encodeTransform encodes a source of message objects. // Transform async *encodeTransform( - source: AsyncIterable | Iterable + source: AsyncIterable | Iterable, ): AsyncIterable { for await (const pkt of source) { if (Array.isArray(pkt)) { @@ -57,7 +57,7 @@ export const EchoMsg = { // decodeTransform decodes a source of encoded messages. // Transform async *decodeTransform( - source: AsyncIterable | Iterable + source: AsyncIterable | Iterable, ): AsyncIterable { for await (const pkt of source) { if (Array.isArray(pkt)) { @@ -71,9 +71,7 @@ export const EchoMsg = { }, fromJSON(object: any): EchoMsg { - return { - body: isSet(object.body) ? String(object.body) : '', - }; + return { body: isSet(object.body) ? String(object.body) : "" }; }, toJSON(message: EchoMsg): unknown { @@ -84,7 +82,7 @@ export const EchoMsg = { fromPartial, I>>(object: I): EchoMsg { const message = createBaseEchoMsg(); - message.body = object.body ?? ''; + message.body = object.body ?? ""; return message; }, }; @@ -112,25 +110,25 @@ export class EchoerClientImpl implements Echoer { } Echo(request: EchoMsg): Promise { const data = EchoMsg.encode(request).finish(); - const promise = this.rpc.request('simple.Echoer', 'Echo', data); + const promise = this.rpc.request("simple.Echoer", "Echo", data); return promise.then((data) => EchoMsg.decode(new _m0.Reader(data))); } EchoServerStream(request: EchoMsg): AsyncIterable { const data = EchoMsg.encode(request).finish(); - const result = this.rpc.serverStreamingRequest('simple.Echoer', 'EchoServerStream', data); + const result = this.rpc.serverStreamingRequest("simple.Echoer", "EchoServerStream", data); return EchoMsg.decodeTransform(result); } EchoClientStream(request: AsyncIterable): Promise { const data = EchoMsg.encodeTransform(request); - const promise = this.rpc.clientStreamingRequest('simple.Echoer', 'EchoClientStream', data); + const promise = this.rpc.clientStreamingRequest("simple.Echoer", "EchoClientStream", data); return promise.then((data) => EchoMsg.decode(new _m0.Reader(data))); } EchoBidiStream(request: AsyncIterable): AsyncIterable { const data = EchoMsg.encodeTransform(request); - const result = this.rpc.bidirectionalStreamingRequest('simple.Echoer', 'EchoBidiStream', data); + const result = this.rpc.bidirectionalStreamingRequest("simple.Echoer", "EchoBidiStream", data); return EchoMsg.decodeTransform(result); } } @@ -142,25 +140,19 @@ interface Rpc { bidirectionalStreamingRequest( service: string, method: string, - data: AsyncIterable + data: AsyncIterable, ): AsyncIterable; } 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/avoid-import-conflicts-types-only/simple.ts b/integration/avoid-import-conflicts-types-only/simple.ts index faf9d6b37..0ac9a1c3c 100644 --- a/integration/avoid-import-conflicts-types-only/simple.ts +++ b/integration/avoid-import-conflicts-types-only/simple.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import type { SimpleEnum as SimpleEnum1, Simple as Simple2 } from './simple2'; +import type { Simple as Simple2, SimpleEnum as SimpleEnum1 } from "./simple2"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export enum SimpleEnum { LOCAL_DEFAULT = 0, diff --git a/integration/avoid-import-conflicts-types-only/simple2.ts b/integration/avoid-import-conflicts-types-only/simple2.ts index ee5dfd906..3a1f32737 100644 --- a/integration/avoid-import-conflicts-types-only/simple2.ts +++ b/integration/avoid-import-conflicts-types-only/simple2.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = 'simple2'; +export const protobufPackage = "simple2"; export enum SimpleEnum { IMPORT_DEFAULT = 0, diff --git a/integration/avoid-import-conflicts/simple.ts b/integration/avoid-import-conflicts/simple.ts index e770abca3..05738586d 100644 --- a/integration/avoid-import-conflicts/simple.ts +++ b/integration/avoid-import-conflicts/simple.ts @@ -1,16 +1,16 @@ /* eslint-disable */ import { - SimpleEnum as SimpleEnum1, FooService as FooService2, + fooServiceFromJSON, + fooServiceToJSON, Simple as Simple3, + SimpleEnum as SimpleEnum1, simpleEnumFromJSON as simpleEnumFromJSON4, simpleEnumToJSON as simpleEnumToJSON5, - fooServiceFromJSON, - fooServiceToJSON, -} from './simple2'; -import * as _m0 from 'protobufjs/minimal'; +} from "./simple2"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export enum SimpleEnum { LOCAL_DEFAULT = 0, @@ -22,16 +22,16 @@ export enum SimpleEnum { export function simpleEnumFromJSON(object: any): SimpleEnum { switch (object) { case 0: - case 'LOCAL_DEFAULT': + case "LOCAL_DEFAULT": return SimpleEnum.LOCAL_DEFAULT; case 1: - case 'LOCAL_FOO': + case "LOCAL_FOO": return SimpleEnum.LOCAL_FOO; case 2: - case 'LOCAL_BAR': + case "LOCAL_BAR": return SimpleEnum.LOCAL_BAR; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return SimpleEnum.UNRECOGNIZED; } @@ -40,14 +40,14 @@ export function simpleEnumFromJSON(object: any): SimpleEnum { export function simpleEnumToJSON(object: SimpleEnum): string { switch (object) { case SimpleEnum.LOCAL_DEFAULT: - return 'LOCAL_DEFAULT'; + return "LOCAL_DEFAULT"; case SimpleEnum.LOCAL_FOO: - return 'LOCAL_FOO'; + return "LOCAL_FOO"; case SimpleEnum.LOCAL_BAR: - return 'LOCAL_BAR'; + return "LOCAL_BAR"; case SimpleEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -70,12 +70,12 @@ export interface FooServiceCreateResponse { } function createBaseSimple(): Simple { - return { name: '', otherSimple: undefined }; + return { name: "", otherSimple: undefined }; } export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.otherSimple !== undefined) { @@ -107,7 +107,7 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", otherSimple: isSet(object.otherSimple) ? Simple3.fromJSON(object.otherSimple) : undefined, }; }, @@ -122,11 +122,10 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; - message.otherSimple = - object.otherSimple !== undefined && object.otherSimple !== null - ? Simple3.fromPartial(object.otherSimple) - : undefined; + message.name = object.name ?? ""; + message.otherSimple = (object.otherSimple !== undefined && object.otherSimple !== null) + ? Simple3.fromPartial(object.otherSimple) + : undefined; return message; }, }; @@ -220,9 +219,7 @@ export const FooServiceCreateRequest = { }, fromJSON(object: any): FooServiceCreateRequest { - return { - kind: isSet(object.kind) ? fooServiceFromJSON(object.kind) : 0, - }; + return { kind: isSet(object.kind) ? fooServiceFromJSON(object.kind) : 0 }; }, toJSON(message: FooServiceCreateRequest): unknown { @@ -269,9 +266,7 @@ export const FooServiceCreateResponse = { }, fromJSON(object: any): FooServiceCreateResponse { - return { - kind: isSet(object.kind) ? fooServiceFromJSON(object.kind) : 0, - }; + return { kind: isSet(object.kind) ? fooServiceFromJSON(object.kind) : 0 }; }, toJSON(message: FooServiceCreateResponse): unknown { @@ -299,7 +294,7 @@ export class FooServiceClientImpl implements FooService { } Create(request: FooServiceCreateRequest): Promise { const data = FooServiceCreateRequest.encode(request).finish(); - const promise = this.rpc.request('simple.FooService', 'Create', data); + const promise = this.rpc.request("simple.FooService", "Create", data); return promise.then((data) => FooServiceCreateResponse.decode(new _m0.Reader(data))); } } @@ -310,19 +305,13 @@ interface Rpc { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/avoid-import-conflicts/simple2.ts b/integration/avoid-import-conflicts/simple2.ts index 635eca397..525c815ae 100644 --- a/integration/avoid-import-conflicts/simple2.ts +++ b/integration/avoid-import-conflicts/simple2.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple2'; +export const protobufPackage = "simple2"; export enum SimpleEnum { IMPORT_DEFAULT = 0, @@ -13,16 +13,16 @@ export enum SimpleEnum { export function simpleEnumFromJSON(object: any): SimpleEnum { switch (object) { case 0: - case 'IMPORT_DEFAULT': + case "IMPORT_DEFAULT": return SimpleEnum.IMPORT_DEFAULT; case 10: - case 'IMPORT_FOO': + case "IMPORT_FOO": return SimpleEnum.IMPORT_FOO; case 11: - case 'IMPORT_BAR': + case "IMPORT_BAR": return SimpleEnum.IMPORT_BAR; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return SimpleEnum.UNRECOGNIZED; } @@ -31,14 +31,14 @@ export function simpleEnumFromJSON(object: any): SimpleEnum { export function simpleEnumToJSON(object: SimpleEnum): string { switch (object) { case SimpleEnum.IMPORT_DEFAULT: - return 'IMPORT_DEFAULT'; + return "IMPORT_DEFAULT"; case SimpleEnum.IMPORT_FOO: - return 'IMPORT_FOO'; + return "IMPORT_FOO"; case SimpleEnum.IMPORT_BAR: - return 'IMPORT_BAR'; + return "IMPORT_BAR"; case SimpleEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -52,16 +52,16 @@ export enum FooService { export function fooServiceFromJSON(object: any): FooService { switch (object) { case 0: - case 'FOO_SERVICE_DEFAULT': + case "FOO_SERVICE_DEFAULT": return FooService.FOO_SERVICE_DEFAULT; case 1: - case 'FOO_SERVICE_FOO': + case "FOO_SERVICE_FOO": return FooService.FOO_SERVICE_FOO; case 2: - case 'FOO_SERVICE_BAR': + case "FOO_SERVICE_BAR": return FooService.FOO_SERVICE_BAR; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return FooService.UNRECOGNIZED; } @@ -70,14 +70,14 @@ export function fooServiceFromJSON(object: any): FooService { export function fooServiceToJSON(object: FooService): string { switch (object) { case FooService.FOO_SERVICE_DEFAULT: - return 'FOO_SERVICE_DEFAULT'; + return "FOO_SERVICE_DEFAULT"; case FooService.FOO_SERVICE_FOO: - return 'FOO_SERVICE_FOO'; + return "FOO_SERVICE_FOO"; case FooService.FOO_SERVICE_BAR: - return 'FOO_SERVICE_BAR'; + return "FOO_SERVICE_BAR"; case FooService.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -87,12 +87,12 @@ export interface Simple { } function createBaseSimple(): Simple { - return { name: '', age: 0 }; + return { name: "", age: 0 }; } export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== 0) { @@ -123,10 +123,7 @@ export const Simple = { }, fromJSON(object: any): Simple { - return { - name: isSet(object.name) ? String(object.name) : '', - age: isSet(object.age) ? Number(object.age) : 0, - }; + return { name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0 }; }, toJSON(message: Simple): unknown { @@ -138,7 +135,7 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.age = object.age ?? 0; return message; }, @@ -146,19 +143,13 @@ export const Simple = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/barrel-imports/bar.ts b/integration/barrel-imports/bar.ts index 414cc96c7..9399746b7 100644 --- a/integration/barrel-imports/bar.ts +++ b/integration/barrel-imports/bar.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; export interface Bar { name: string; @@ -7,12 +7,12 @@ export interface Bar { } function createBaseBar(): Bar { - return { name: '', age: 0 }; + return { name: "", age: 0 }; } export const Bar = { encode(message: Bar, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== 0) { @@ -43,10 +43,7 @@ export const Bar = { }, fromJSON(object: any): Bar { - return { - name: isSet(object.name) ? String(object.name) : '', - age: isSet(object.age) ? Number(object.age) : 0, - }; + return { name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0 }; }, toJSON(message: Bar): unknown { @@ -58,7 +55,7 @@ export const Bar = { fromPartial, I>>(object: I): Bar { const message = createBaseBar(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.age = object.age ?? 0; return message; }, @@ -66,19 +63,13 @@ export const Bar = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +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; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/barrel-imports/foo.ts b/integration/barrel-imports/foo.ts index 4e8083f2b..e0107e4a6 100644 --- a/integration/barrel-imports/foo.ts +++ b/integration/barrel-imports/foo.ts @@ -1,6 +1,6 @@ /* eslint-disable */ -import { Bar } from './bar'; -import * as _m0 from 'protobufjs/minimal'; +import { Bar } from "./bar"; +import * as _m0 from "protobufjs/minimal"; export interface Foo { name: string; @@ -8,12 +8,12 @@ export interface Foo { } function createBaseFoo(): Foo { - return { name: '', bar: undefined }; + return { name: "", bar: undefined }; } export const Foo = { encode(message: Foo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.bar !== undefined) { @@ -45,7 +45,7 @@ export const Foo = { fromJSON(object: any): Foo { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", bar: isSet(object.bar) ? Bar.fromJSON(object.bar) : undefined, }; }, @@ -59,27 +59,21 @@ export const Foo = { fromPartial, I>>(object: I): Foo { const message = createBaseFoo(); - message.name = object.name ?? ''; - message.bar = object.bar !== undefined && object.bar !== null ? Bar.fromPartial(object.bar) : undefined; + message.name = object.name ?? ""; + message.bar = (object.bar !== undefined && object.bar !== null) ? Bar.fromPartial(object.bar) : undefined; return message; }, }; type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -type DeepPartial = T extends Builtin - ? T - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +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; -type Exact = P extends Builtin - ? P +type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/batching-with-context/batching.ts b/integration/batching-with-context/batching.ts index 169c0e6ab..348ebbe2d 100644 --- a/integration/batching-with-context/batching.ts +++ b/integration/batching-with-context/batching.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import * as DataLoader from 'dataloader'; -import * as hash from 'object-hash'; -import * as _m0 from 'protobufjs/minimal'; +import * as DataLoader from "dataloader"; +import * as hash from "object-hash"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'batching'; +export const protobufPackage = "batching"; export interface BatchQueryRequest { ids: string[]; @@ -38,7 +38,8 @@ export interface WriteMethodRequest { id: string; } -export interface WriteMethodResponse {} +export interface WriteMethodResponse { +} export interface Entity { id: string; @@ -76,9 +77,7 @@ export const BatchQueryRequest = { }, fromJSON(object: any): BatchQueryRequest { - return { - ids: Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [], - }; + return { ids: Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] }; }, toJSON(message: BatchQueryRequest): unknown { @@ -129,15 +128,13 @@ export const BatchQueryResponse = { }, fromJSON(object: any): BatchQueryResponse { - return { - entities: Array.isArray(object?.entities) ? object.entities.map((e: any) => Entity.fromJSON(e)) : [], - }; + return { entities: Array.isArray(object?.entities) ? object.entities.map((e: any) => Entity.fromJSON(e)) : [] }; }, toJSON(message: BatchQueryResponse): unknown { const obj: any = {}; if (message.entities) { - obj.entities = message.entities.map((e) => (e ? Entity.toJSON(e) : undefined)); + obj.entities = message.entities.map((e) => e ? Entity.toJSON(e) : undefined); } else { obj.entities = []; } @@ -182,9 +179,7 @@ export const BatchMapQueryRequest = { }, fromJSON(object: any): BatchMapQueryRequest { - return { - ids: Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [], - }; + return { ids: Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] }; }, toJSON(message: BatchMapQueryRequest): unknown { @@ -241,9 +236,9 @@ export const BatchMapQueryResponse = { return { entities: isObject(object.entities) ? Object.entries(object.entities).reduce<{ [key: string]: Entity }>((acc, [key, value]) => { - acc[key] = Entity.fromJSON(value); - return acc; - }, {}) + acc[key] = Entity.fromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -272,12 +267,12 @@ export const BatchMapQueryResponse = { }; function createBaseBatchMapQueryResponse_EntitiesEntry(): BatchMapQueryResponse_EntitiesEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const BatchMapQueryResponse_EntitiesEntry = { encode(message: BatchMapQueryResponse_EntitiesEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -309,7 +304,7 @@ export const BatchMapQueryResponse_EntitiesEntry = { fromJSON(object: any): BatchMapQueryResponse_EntitiesEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -322,22 +317,24 @@ export const BatchMapQueryResponse_EntitiesEntry = { }, fromPartial, I>>( - object: I + object: I, ): BatchMapQueryResponse_EntitiesEntry { const message = createBaseBatchMapQueryResponse_EntitiesEntry(); - message.key = object.key ?? ''; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.key = object.key ?? ""; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; function createBaseGetOnlyMethodRequest(): GetOnlyMethodRequest { - return { id: '' }; + return { id: "" }; } export const GetOnlyMethodRequest = { encode(message: GetOnlyMethodRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== '') { + if (message.id !== "") { writer.uint32(10).string(message.id); } return writer; @@ -362,9 +359,7 @@ export const GetOnlyMethodRequest = { }, fromJSON(object: any): GetOnlyMethodRequest { - return { - id: isSet(object.id) ? String(object.id) : '', - }; + return { id: isSet(object.id) ? String(object.id) : "" }; }, toJSON(message: GetOnlyMethodRequest): unknown { @@ -375,7 +370,7 @@ export const GetOnlyMethodRequest = { fromPartial, I>>(object: I): GetOnlyMethodRequest { const message = createBaseGetOnlyMethodRequest(); - message.id = object.id ?? ''; + message.id = object.id ?? ""; return message; }, }; @@ -411,9 +406,7 @@ export const GetOnlyMethodResponse = { }, fromJSON(object: any): GetOnlyMethodResponse { - return { - entity: isSet(object.entity) ? Entity.fromJSON(object.entity) : undefined, - }; + return { entity: isSet(object.entity) ? Entity.fromJSON(object.entity) : undefined }; }, toJSON(message: GetOnlyMethodResponse): unknown { @@ -424,19 +417,20 @@ export const GetOnlyMethodResponse = { fromPartial, I>>(object: I): GetOnlyMethodResponse { const message = createBaseGetOnlyMethodResponse(); - message.entity = - object.entity !== undefined && object.entity !== null ? Entity.fromPartial(object.entity) : undefined; + message.entity = (object.entity !== undefined && object.entity !== null) + ? Entity.fromPartial(object.entity) + : undefined; return message; }, }; function createBaseWriteMethodRequest(): WriteMethodRequest { - return { id: '' }; + return { id: "" }; } export const WriteMethodRequest = { encode(message: WriteMethodRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== '') { + if (message.id !== "") { writer.uint32(10).string(message.id); } return writer; @@ -461,9 +455,7 @@ export const WriteMethodRequest = { }, fromJSON(object: any): WriteMethodRequest { - return { - id: isSet(object.id) ? String(object.id) : '', - }; + return { id: isSet(object.id) ? String(object.id) : "" }; }, toJSON(message: WriteMethodRequest): unknown { @@ -474,7 +466,7 @@ export const WriteMethodRequest = { fromPartial, I>>(object: I): WriteMethodRequest { const message = createBaseWriteMethodRequest(); - message.id = object.id ?? ''; + message.id = object.id ?? ""; return message; }, }; @@ -519,15 +511,15 @@ export const WriteMethodResponse = { }; function createBaseEntity(): Entity { - return { id: '', name: '' }; + return { id: "", name: "" }; } export const Entity = { encode(message: Entity, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== '') { + if (message.id !== "") { writer.uint32(10).string(message.id); } - if (message.name !== '') { + if (message.name !== "") { writer.uint32(18).string(message.name); } return writer; @@ -555,10 +547,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { - id: isSet(object.id) ? String(object.id) : '', - name: isSet(object.name) ? String(object.name) : '', - }; + return { id: isSet(object.id) ? String(object.id) : "", name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Entity): unknown { @@ -570,8 +559,8 @@ export const Entity = { fromPartial, I>>(object: I): Entity { const message = createBaseEntity(); - message.id = object.id ?? ''; - message.name = object.name ?? ''; + message.id = object.id ?? ""; + message.name = object.name ?? ""; return message; }, }; @@ -597,65 +586,56 @@ export class EntityServiceClientImpl implements Ent this.WriteMethod = this.WriteMethod.bind(this); } GetQuery(ctx: Context, id: string): Promise { - const dl = ctx.getDataLoader('batching.EntityService.BatchQuery', () => { - return new DataLoader( - (ids) => { - const request = { ids }; - return this.BatchQuery(ctx, request).then((res) => res.entities); - }, - { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions } - ); + const dl = ctx.getDataLoader("batching.EntityService.BatchQuery", () => { + return new DataLoader((ids) => { + const request = { ids }; + return this.BatchQuery(ctx, request).then((res) => res.entities); + }, { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions }); }); return dl.load(id); } BatchQuery(ctx: Context, request: BatchQueryRequest): Promise { const data = BatchQueryRequest.encode(request).finish(); - const promise = this.rpc.request(ctx, 'batching.EntityService', 'BatchQuery', data); + const promise = this.rpc.request(ctx, "batching.EntityService", "BatchQuery", data); return promise.then((data) => BatchQueryResponse.decode(new _m0.Reader(data))); } GetMapQuery(ctx: Context, id: string): Promise { - const dl = ctx.getDataLoader('batching.EntityService.BatchMapQuery', () => { - return new DataLoader( - (ids) => { - const request = { ids }; - return this.BatchMapQuery(ctx, request).then((res) => { - return ids.map((key) => res.entities[key]); - }); - }, - { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions } - ); + const dl = ctx.getDataLoader("batching.EntityService.BatchMapQuery", () => { + return new DataLoader((ids) => { + const request = { ids }; + return this.BatchMapQuery(ctx, request).then((res) => { + return ids.map((key) => res.entities[key]); + }); + }, { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions }); }); return dl.load(id); } BatchMapQuery(ctx: Context, request: BatchMapQueryRequest): Promise { const data = BatchMapQueryRequest.encode(request).finish(); - const promise = this.rpc.request(ctx, 'batching.EntityService', 'BatchMapQuery', data); + const promise = this.rpc.request(ctx, "batching.EntityService", "BatchMapQuery", data); return promise.then((data) => BatchMapQueryResponse.decode(new _m0.Reader(data))); } GetOnlyMethod(ctx: Context, request: GetOnlyMethodRequest): Promise { - const dl = ctx.getDataLoader('batching.EntityService.GetOnlyMethod', () => { - return new DataLoader( - (requests) => { - const responses = requests.map(async (request) => { - const data = GetOnlyMethodRequest.encode(request).finish(); - const response = await this.rpc.request(ctx, 'batching.EntityService', 'GetOnlyMethod', data); - return GetOnlyMethodResponse.decode(new _m0.Reader(response)); - }); - return Promise.all(responses); - }, - { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions } - ); + const dl = ctx.getDataLoader("batching.EntityService.GetOnlyMethod", () => { + return new DataLoader((requests) => { + const responses = requests.map(async (request) => { + const data = GetOnlyMethodRequest.encode(request).finish(); + const response = await this.rpc.request(ctx, "batching.EntityService", "GetOnlyMethod", data); + return GetOnlyMethodResponse.decode(new _m0.Reader(response)); + }); + return Promise.all(responses); + }, { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions }); }); return dl.load(request); } WriteMethod(ctx: Context, request: WriteMethodRequest): Promise { const data = WriteMethodRequest.encode(request).finish(); - const promise = this.rpc.request(ctx, 'batching.EntityService', 'WriteMethod', data); + const promise = this.rpc.request(ctx, "batching.EntityService", "WriteMethod", data); return promise.then((data) => WriteMethodResponse.decode(new _m0.Reader(data))); } } @@ -675,23 +655,17 @@ export interface DataLoaders { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/batching/batching.ts b/integration/batching/batching.ts index b73dce206..e7e3a3070 100644 --- a/integration/batching/batching.ts +++ b/integration/batching/batching.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'batching'; +export const protobufPackage = "batching"; export interface BatchQueryRequest { ids: string[]; @@ -36,7 +36,8 @@ export interface WriteMethodRequest { id: string; } -export interface WriteMethodResponse {} +export interface WriteMethodResponse { +} export interface Entity { id: string; @@ -74,9 +75,7 @@ export const BatchQueryRequest = { }, fromJSON(object: any): BatchQueryRequest { - return { - ids: Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [], - }; + return { ids: Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] }; }, toJSON(message: BatchQueryRequest): unknown { @@ -127,15 +126,13 @@ export const BatchQueryResponse = { }, fromJSON(object: any): BatchQueryResponse { - return { - entities: Array.isArray(object?.entities) ? object.entities.map((e: any) => Entity.fromJSON(e)) : [], - }; + return { entities: Array.isArray(object?.entities) ? object.entities.map((e: any) => Entity.fromJSON(e)) : [] }; }, toJSON(message: BatchQueryResponse): unknown { const obj: any = {}; if (message.entities) { - obj.entities = message.entities.map((e) => (e ? Entity.toJSON(e) : undefined)); + obj.entities = message.entities.map((e) => e ? Entity.toJSON(e) : undefined); } else { obj.entities = []; } @@ -180,9 +177,7 @@ export const BatchMapQueryRequest = { }, fromJSON(object: any): BatchMapQueryRequest { - return { - ids: Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [], - }; + return { ids: Array.isArray(object?.ids) ? object.ids.map((e: any) => String(e)) : [] }; }, toJSON(message: BatchMapQueryRequest): unknown { @@ -239,9 +234,9 @@ export const BatchMapQueryResponse = { return { entities: isObject(object.entities) ? Object.entries(object.entities).reduce<{ [key: string]: Entity }>((acc, [key, value]) => { - acc[key] = Entity.fromJSON(value); - return acc; - }, {}) + acc[key] = Entity.fromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -270,12 +265,12 @@ export const BatchMapQueryResponse = { }; function createBaseBatchMapQueryResponse_EntitiesEntry(): BatchMapQueryResponse_EntitiesEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const BatchMapQueryResponse_EntitiesEntry = { encode(message: BatchMapQueryResponse_EntitiesEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -307,7 +302,7 @@ export const BatchMapQueryResponse_EntitiesEntry = { fromJSON(object: any): BatchMapQueryResponse_EntitiesEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? Entity.fromJSON(object.value) : undefined, }; }, @@ -320,22 +315,24 @@ export const BatchMapQueryResponse_EntitiesEntry = { }, fromPartial, I>>( - object: I + object: I, ): BatchMapQueryResponse_EntitiesEntry { const message = createBaseBatchMapQueryResponse_EntitiesEntry(); - message.key = object.key ?? ''; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.key = object.key ?? ""; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; function createBaseGetOnlyMethodRequest(): GetOnlyMethodRequest { - return { id: '' }; + return { id: "" }; } export const GetOnlyMethodRequest = { encode(message: GetOnlyMethodRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== '') { + if (message.id !== "") { writer.uint32(10).string(message.id); } return writer; @@ -360,9 +357,7 @@ export const GetOnlyMethodRequest = { }, fromJSON(object: any): GetOnlyMethodRequest { - return { - id: isSet(object.id) ? String(object.id) : '', - }; + return { id: isSet(object.id) ? String(object.id) : "" }; }, toJSON(message: GetOnlyMethodRequest): unknown { @@ -373,7 +368,7 @@ export const GetOnlyMethodRequest = { fromPartial, I>>(object: I): GetOnlyMethodRequest { const message = createBaseGetOnlyMethodRequest(); - message.id = object.id ?? ''; + message.id = object.id ?? ""; return message; }, }; @@ -409,9 +404,7 @@ export const GetOnlyMethodResponse = { }, fromJSON(object: any): GetOnlyMethodResponse { - return { - entity: isSet(object.entity) ? Entity.fromJSON(object.entity) : undefined, - }; + return { entity: isSet(object.entity) ? Entity.fromJSON(object.entity) : undefined }; }, toJSON(message: GetOnlyMethodResponse): unknown { @@ -422,19 +415,20 @@ export const GetOnlyMethodResponse = { fromPartial, I>>(object: I): GetOnlyMethodResponse { const message = createBaseGetOnlyMethodResponse(); - message.entity = - object.entity !== undefined && object.entity !== null ? Entity.fromPartial(object.entity) : undefined; + message.entity = (object.entity !== undefined && object.entity !== null) + ? Entity.fromPartial(object.entity) + : undefined; return message; }, }; function createBaseWriteMethodRequest(): WriteMethodRequest { - return { id: '' }; + return { id: "" }; } export const WriteMethodRequest = { encode(message: WriteMethodRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== '') { + if (message.id !== "") { writer.uint32(10).string(message.id); } return writer; @@ -459,9 +453,7 @@ export const WriteMethodRequest = { }, fromJSON(object: any): WriteMethodRequest { - return { - id: isSet(object.id) ? String(object.id) : '', - }; + return { id: isSet(object.id) ? String(object.id) : "" }; }, toJSON(message: WriteMethodRequest): unknown { @@ -472,7 +464,7 @@ export const WriteMethodRequest = { fromPartial, I>>(object: I): WriteMethodRequest { const message = createBaseWriteMethodRequest(); - message.id = object.id ?? ''; + message.id = object.id ?? ""; return message; }, }; @@ -517,15 +509,15 @@ export const WriteMethodResponse = { }; function createBaseEntity(): Entity { - return { id: '', name: '' }; + return { id: "", name: "" }; } export const Entity = { encode(message: Entity, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== '') { + if (message.id !== "") { writer.uint32(10).string(message.id); } - if (message.name !== '') { + if (message.name !== "") { writer.uint32(18).string(message.name); } return writer; @@ -553,10 +545,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { - id: isSet(object.id) ? String(object.id) : '', - name: isSet(object.name) ? String(object.name) : '', - }; + return { id: isSet(object.id) ? String(object.id) : "", name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Entity): unknown { @@ -568,8 +557,8 @@ export const Entity = { fromPartial, I>>(object: I): Entity { const message = createBaseEntity(); - message.id = object.id ?? ''; - message.name = object.name ?? ''; + message.id = object.id ?? ""; + message.name = object.name ?? ""; return message; }, }; @@ -594,25 +583,25 @@ export class EntityServiceClientImpl implements EntityService { } BatchQuery(request: BatchQueryRequest): Promise { const data = BatchQueryRequest.encode(request).finish(); - const promise = this.rpc.request('batching.EntityService', 'BatchQuery', data); + const promise = this.rpc.request("batching.EntityService", "BatchQuery", data); return promise.then((data) => BatchQueryResponse.decode(new _m0.Reader(data))); } BatchMapQuery(request: BatchMapQueryRequest): Promise { const data = BatchMapQueryRequest.encode(request).finish(); - const promise = this.rpc.request('batching.EntityService', 'BatchMapQuery', data); + const promise = this.rpc.request("batching.EntityService", "BatchMapQuery", data); return promise.then((data) => BatchMapQueryResponse.decode(new _m0.Reader(data))); } GetOnlyMethod(request: GetOnlyMethodRequest): Promise { const data = GetOnlyMethodRequest.encode(request).finish(); - const promise = this.rpc.request('batching.EntityService', 'GetOnlyMethod', data); + const promise = this.rpc.request("batching.EntityService", "GetOnlyMethod", data); return promise.then((data) => GetOnlyMethodResponse.decode(new _m0.Reader(data))); } WriteMethod(request: WriteMethodRequest): Promise { const data = WriteMethodRequest.encode(request).finish(); - const promise = this.rpc.request('batching.EntityService', 'WriteMethod', data); + const promise = this.rpc.request("batching.EntityService", "WriteMethod", data); return promise.then((data) => WriteMethodResponse.decode(new _m0.Reader(data))); } } @@ -623,23 +612,17 @@ interface Rpc { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/bytes-as-base64/message.ts b/integration/bytes-as-base64/message.ts index 28a399610..1ffb1108d 100644 --- a/integration/bytes-as-base64/message.ts +++ b/integration/bytes-as-base64/message.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = ''; +export const protobufPackage = ""; export interface Message { data: Uint8Array; @@ -11,9 +11,7 @@ function createBaseMessage(): Message { export const Message = { fromJSON(object: any): Message { - return { - data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), - }; + return { data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array() }; }, toJSON(message: Message): unknown { @@ -34,16 +32,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -56,31 +62,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/bytes-node/google/protobuf/wrappers.ts b/integration/bytes-node/google/protobuf/wrappers.ts index 7d4e0d092..d1b77e648 100644 --- a/integration/bytes-node/google/protobuf/wrappers.ts +++ b/integration/bytes-node/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial, I>>(object: I): StringValue { const message = createBaseStringValue(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? Buffer.from(bytesFromBase64(object.value)) : Buffer.alloc(0), - }; + return { value: isSet(object.value) ? Buffer.from(bytesFromBase64(object.value)) : Buffer.alloc(0) }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,36 +552,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/bytes-node/point.ts b/integration/bytes-node/point.ts index 52be33ec5..ee299e099 100644 --- a/integration/bytes-node/point.ts +++ b/integration/bytes-node/point.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; -import { BytesValue } from './google/protobuf/wrappers'; +import * as _m0 from "protobufjs/minimal"; +import { BytesValue } from "./google/protobuf/wrappers"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface Point { data: Buffer; @@ -72,16 +72,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -94,31 +102,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/codegen.sh b/integration/codegen.sh index 9226ac932..d2ad44d3f 100755 --- a/integration/codegen.sh +++ b/integration/codegen.sh @@ -52,7 +52,7 @@ for BIN_FILE in $BIN_FILES; do fi ((i=i%N)); ((i++==0)) && wait - "../node_modules/.bin/ts-node" "./codegen.ts" "${TEST_DIR}" "${BIN_FILE}" "${PARAMS}" & + "../node_modules/.bin/tsx" "./codegen.ts" "${TEST_DIR}" "${BIN_FILE}" "${PARAMS}" & done wait diff --git a/integration/codegen.ts b/integration/codegen.ts index 25a37d535..16e77a21c 100644 --- a/integration/codegen.ts +++ b/integration/codegen.ts @@ -1,13 +1,13 @@ -import { CodeGeneratorRequest } from 'ts-proto-descriptors'; -import { mkdir, readFile, writeFile } from 'fs'; -import { parse } from 'path'; -import { promisify } from 'util'; -import { generateFile, makeUtils } from '../src/main'; -import { createTypeMap } from '../src/types'; -import { prefixDisableLinter } from '../src/utils'; -import { getTsPoetOpts, optionsFromParameter } from '../src/options'; -import { Context } from '../src/context'; -import { generateTypeRegistry } from '../src/generate-type-registry'; +import { CodeGeneratorRequest } from "ts-proto-descriptors"; +import { mkdir, readFile, writeFile } from "fs"; +import { parse } from "path"; +import { promisify } from "util"; +import { generateFile, makeUtils } from "../src/main"; +import { createTypeMap } from "../src/types"; +import { prefixDisableLinter } from "../src/utils"; +import { getTsPoetOpts, optionsFromParameter } from "../src/options"; +import { Context } from "../src/context"; +import { generateTypeRegistry } from "../src/generate-type-registry"; /** * Generates output for our integration tests from their example proto files. @@ -28,7 +28,7 @@ async function generate(binFile: string, baseDir: string, parameter: string) { const request = CodeGeneratorRequest.decode(stdin); request.parameter = parameter; - const options = optionsFromParameter(parameter || ''); + const options = optionsFromParameter(parameter || ""); const typeMap = createTypeMap(request, options); for (let file of request.protoFile) { @@ -49,7 +49,7 @@ async function generate(binFile: string, baseDir: string, parameter: string) { const utils = makeUtils(options); const ctx: Context = { options, typeMap, utils }; - const path = 'typeRegistry.ts'; + const path = "typeRegistry.ts"; const code = generateTypeRegistry(ctx); const filePath = `${baseDir}/${path}`; diff --git a/integration/const-enum/const-enum.ts b/integration/const-enum/const-enum.ts index 428cfa245..4cdd491e7 100644 --- a/integration/const-enum/const-enum.ts +++ b/integration/const-enum/const-enum.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface DividerData { type: DividerData_DividerType; @@ -9,29 +9,29 @@ export interface DividerData { } export const enum DividerData_DividerType { - DOUBLE = 'DOUBLE', - SINGLE = 'SINGLE', - DASHED = 'DASHED', - DOTTED = 'DOTTED', - UNRECOGNIZED = 'UNRECOGNIZED', + DOUBLE = "DOUBLE", + SINGLE = "SINGLE", + DASHED = "DASHED", + DOTTED = "DOTTED", + UNRECOGNIZED = "UNRECOGNIZED", } export function dividerData_DividerTypeFromJSON(object: any): DividerData_DividerType { switch (object) { case 0: - case 'DOUBLE': + case "DOUBLE": return DividerData_DividerType.DOUBLE; case 1: - case 'SINGLE': + case "SINGLE": return DividerData_DividerType.SINGLE; case 2: - case 'DASHED': + case "DASHED": return DividerData_DividerType.DASHED; case 3: - case 'DOTTED': + case "DOTTED": return DividerData_DividerType.DOTTED; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return DividerData_DividerType.UNRECOGNIZED; } @@ -40,16 +40,16 @@ export function dividerData_DividerTypeFromJSON(object: any): DividerData_Divide export function dividerData_DividerTypeToJSON(object: DividerData_DividerType): string { switch (object) { case DividerData_DividerType.DOUBLE: - return 'DOUBLE'; + return "DOUBLE"; case DividerData_DividerType.SINGLE: - return 'SINGLE'; + return "SINGLE"; case DividerData_DividerType.DASHED: - return 'DASHED'; + return "DASHED"; case DividerData_DividerType.DOTTED: - return 'DOTTED'; + return "DOTTED"; case DividerData_DividerType.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -118,9 +118,9 @@ export const DividerData = { type: isSet(object.type) ? dividerData_DividerTypeFromJSON(object.type) : DividerData_DividerType.DOUBLE, typeMap: isObject(object.typeMap) ? Object.entries(object.typeMap).reduce<{ [key: string]: DividerData_DividerType }>((acc, [key, value]) => { - acc[key] = dividerData_DividerTypeFromJSON(value); - return acc; - }, {}) + acc[key] = dividerData_DividerTypeFromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -147,19 +147,19 @@ export const DividerData = { } return acc; }, - {} + {}, ); return message; }, }; function createBaseDividerData_TypeMapEntry(): DividerData_TypeMapEntry { - return { key: '', value: DividerData_DividerType.DOUBLE }; + return { key: "", value: DividerData_DividerType.DOUBLE }; } export const DividerData_TypeMapEntry = { encode(message: DividerData_TypeMapEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== DividerData_DividerType.DOUBLE) { @@ -191,7 +191,7 @@ export const DividerData_TypeMapEntry = { fromJSON(object: any): DividerData_TypeMapEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? dividerData_DividerTypeFromJSON(object.value) : DividerData_DividerType.DOUBLE, }; }, @@ -205,7 +205,7 @@ export const DividerData_TypeMapEntry = { fromPartial, I>>(object: I): DividerData_TypeMapEntry { const message = createBaseDividerData_TypeMapEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? DividerData_DividerType.DOUBLE; return message; }, @@ -213,23 +213,17 @@ export const DividerData_TypeMapEntry = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts b/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts index 125984781..80ba6f3c3 100644 --- a/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts +++ b/integration/enums-as-literals-with-string-enums/enums-as-literals-with-string-enums.ts @@ -1,18 +1,18 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface DividerData { type: DividerData_DividerType; } export const DividerData_DividerType = { - DOUBLE: 'DOUBLE', - SINGLE: 'SINGLE', - DASHED: 'DASHED', - DOTTED: 'DOTTED', - UNRECOGNIZED: 'UNRECOGNIZED', + DOUBLE: "DOUBLE", + SINGLE: "SINGLE", + DASHED: "DASHED", + DOTTED: "DOTTED", + UNRECOGNIZED: "UNRECOGNIZED", } as const; export type DividerData_DividerType = typeof DividerData_DividerType[keyof typeof DividerData_DividerType]; @@ -20,19 +20,19 @@ export type DividerData_DividerType = typeof DividerData_DividerType[keyof typeo export function dividerData_DividerTypeFromJSON(object: any): DividerData_DividerType { switch (object) { case 0: - case 'DOUBLE': + case "DOUBLE": return DividerData_DividerType.DOUBLE; case 1: - case 'SINGLE': + case "SINGLE": return DividerData_DividerType.SINGLE; case 2: - case 'DASHED': + case "DASHED": return DividerData_DividerType.DASHED; case 3: - case 'DOTTED': + case "DOTTED": return DividerData_DividerType.DOTTED; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return DividerData_DividerType.UNRECOGNIZED; } @@ -41,16 +41,16 @@ export function dividerData_DividerTypeFromJSON(object: any): DividerData_Divide export function dividerData_DividerTypeToJSON(object: DividerData_DividerType): string { switch (object) { case DividerData_DividerType.DOUBLE: - return 'DOUBLE'; + return "DOUBLE"; case DividerData_DividerType.SINGLE: - return 'SINGLE'; + return "SINGLE"; case DividerData_DividerType.DASHED: - return 'DASHED'; + return "DASHED"; case DividerData_DividerType.DOTTED: - return 'DOTTED'; + return "DOTTED"; case DividerData_DividerType.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -101,9 +101,7 @@ export const DividerData = { }, fromJSON(object: any): DividerData { - return { - type: isSet(object.type) ? dividerData_DividerTypeFromJSON(object.type) : DividerData_DividerType.DOUBLE, - }; + return { type: isSet(object.type) ? dividerData_DividerTypeFromJSON(object.type) : DividerData_DividerType.DOUBLE }; }, toJSON(message: DividerData): unknown { @@ -121,19 +119,13 @@ export const DividerData = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/enums-as-literals/enums-as-literals.ts b/integration/enums-as-literals/enums-as-literals.ts index 0209f5ae2..2af7729b7 100644 --- a/integration/enums-as-literals/enums-as-literals.ts +++ b/integration/enums-as-literals/enums-as-literals.ts @@ -1,38 +1,32 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface DividerData { type: DividerData_DividerType; } -export const DividerData_DividerType = { - DOUBLE: 0, - SINGLE: 1, - DASHED: 2, - DOTTED: 3, - UNRECOGNIZED: -1, -} as const; +export const DividerData_DividerType = { DOUBLE: 0, SINGLE: 1, DASHED: 2, DOTTED: 3, UNRECOGNIZED: -1 } as const; export type DividerData_DividerType = typeof DividerData_DividerType[keyof typeof DividerData_DividerType]; export function dividerData_DividerTypeFromJSON(object: any): DividerData_DividerType { switch (object) { case 0: - case 'DOUBLE': + case "DOUBLE": return DividerData_DividerType.DOUBLE; case 1: - case 'SINGLE': + case "SINGLE": return DividerData_DividerType.SINGLE; case 2: - case 'DASHED': + case "DASHED": return DividerData_DividerType.DASHED; case 3: - case 'DOTTED': + case "DOTTED": return DividerData_DividerType.DOTTED; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return DividerData_DividerType.UNRECOGNIZED; } @@ -41,16 +35,16 @@ export function dividerData_DividerTypeFromJSON(object: any): DividerData_Divide export function dividerData_DividerTypeToJSON(object: DividerData_DividerType): string { switch (object) { case DividerData_DividerType.DOUBLE: - return 'DOUBLE'; + return "DOUBLE"; case DividerData_DividerType.SINGLE: - return 'SINGLE'; + return "SINGLE"; case DividerData_DividerType.DASHED: - return 'DASHED'; + return "DASHED"; case DividerData_DividerType.DOTTED: - return 'DOTTED'; + return "DOTTED"; case DividerData_DividerType.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -85,9 +79,7 @@ export const DividerData = { }, fromJSON(object: any): DividerData { - return { - type: isSet(object.type) ? dividerData_DividerTypeFromJSON(object.type) : 0, - }; + return { type: isSet(object.type) ? dividerData_DividerTypeFromJSON(object.type) : 0 }; }, toJSON(message: DividerData): unknown { @@ -105,19 +97,13 @@ export const DividerData = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/fieldmask/fieldmask.ts b/integration/fieldmask/fieldmask.ts index c948fe4fb..7dfc7c97a 100644 --- a/integration/fieldmask/fieldmask.ts +++ b/integration/fieldmask/fieldmask.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; -import { FieldMask } from './google/protobuf/field_mask'; +import * as _m0 from "protobufjs/minimal"; +import { FieldMask } from "./google/protobuf/field_mask"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface FieldMaskMessage { fieldMask: string[] | undefined; @@ -39,9 +39,7 @@ export const FieldMaskMessage = { }, fromJSON(object: any): FieldMaskMessage { - return { - fieldMask: isSet(object.fieldMask) ? FieldMask.unwrap(FieldMask.fromJSON(object.fieldMask)) : undefined, - }; + return { fieldMask: isSet(object.fieldMask) ? FieldMask.unwrap(FieldMask.fromJSON(object.fieldMask)) : undefined }; }, toJSON(message: FieldMaskMessage): unknown { @@ -59,19 +57,13 @@ export const FieldMaskMessage = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/fieldmask/google/protobuf/field_mask.ts b/integration/fieldmask/google/protobuf/field_mask.ts index 1895f208e..2cc7de908 100644 --- a/integration/fieldmask/google/protobuf/field_mask.ts +++ b/integration/fieldmask/google/protobuf/field_mask.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `FieldMask` represents a set of symbolic field paths, for example: @@ -38,7 +38,6 @@ export const protobufPackage = 'google.protobuf'; * (their value will be set to the default, and omitted in proto text * output): * - * * f { * a : 22 * b { @@ -241,17 +240,16 @@ export const FieldMask = { fromJSON(object: any): FieldMask { return { - paths: - typeof object === 'string' - ? object.split(',').filter(Boolean) - : Array.isArray(object?.paths) - ? object.paths.map(String) - : [], + paths: typeof (object) === "string" + ? object.split(",").filter(Boolean) + : Array.isArray(object?.paths) + ? object.paths.map(String) + : [], }; }, toJSON(message: FieldMask): string { - return message.paths.join(','); + return message.paths.join(","); }, fromPartial, I>>(object: I): FieldMask { @@ -275,17 +273,11 @@ export const FieldMask = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; diff --git a/integration/file-suffix/child.pb.ts b/integration/file-suffix/child.pb.ts index 56d958f80..aa83fbad4 100644 --- a/integration/file-suffix/child.pb.ts +++ b/integration/file-suffix/child.pb.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'file_suffix'; +export const protobufPackage = "file_suffix"; export enum ChildEnum { DEFAULT = 0, @@ -12,13 +12,13 @@ export enum ChildEnum { export function childEnumFromJSON(object: any): ChildEnum { switch (object) { case 0: - case 'DEFAULT': + case "DEFAULT": return ChildEnum.DEFAULT; case 1: - case 'FOO': + case "FOO": return ChildEnum.FOO; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return ChildEnum.UNRECOGNIZED; } @@ -27,12 +27,12 @@ export function childEnumFromJSON(object: any): ChildEnum { export function childEnumToJSON(object: ChildEnum): string { switch (object) { case ChildEnum.DEFAULT: - return 'DEFAULT'; + return "DEFAULT"; case ChildEnum.FOO: - return 'FOO'; + return "FOO"; case ChildEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -41,12 +41,12 @@ export interface Child { } function createBaseChild(): Child { - return { name: '' }; + return { name: "" }; } export const Child = { encode(message: Child, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -71,9 +71,7 @@ export const Child = { }, fromJSON(object: any): Child { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Child): unknown { @@ -84,26 +82,20 @@ export const Child = { fromPartial, I>>(object: I): Child { const message = createBaseChild(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/file-suffix/google/protobuf/timestamp.pb.ts b/integration/file-suffix/google/protobuf/timestamp.pb.ts index c52fb2549..5497f7183 100644 --- a/integration/file-suffix/google/protobuf/timestamp.pb.ts +++ b/integration/file-suffix/google/protobuf/timestamp.pb.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/file-suffix/parent.pb.ts b/integration/file-suffix/parent.pb.ts index 0e01af696..e4eb10e35 100644 --- a/integration/file-suffix/parent.pb.ts +++ b/integration/file-suffix/parent.pb.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { ChildEnum, Child, childEnumFromJSON, childEnumToJSON } from './child.pb'; -import { Timestamp } from './google/protobuf/timestamp.pb'; -import * as _m0 from 'protobufjs/minimal'; +import { Child, ChildEnum, childEnumFromJSON, childEnumToJSON } from "./child.pb"; +import { Timestamp } from "./google/protobuf/timestamp.pb"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'file_suffix'; +export const protobufPackage = "file_suffix"; export interface Parent { child: Child | undefined; @@ -71,7 +71,7 @@ export const Parent = { fromPartial, I>>(object: I): Parent { const message = createBaseParent(); - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; message.childEnum = object.childEnum ?? 0; message.createdAt = object.createdAt ?? undefined; return message; @@ -80,19 +80,13 @@ export const Parent = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -110,7 +104,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/generic-metadata/hero.ts b/integration/generic-metadata/hero.ts index e3399a1e8..7abf33809 100644 --- a/integration/generic-metadata/hero.ts +++ b/integration/generic-metadata/hero.ts @@ -1,10 +1,10 @@ /* eslint-disable */ -import { Foo } from './some-file'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import * as _m0 from 'protobufjs/minimal'; +import { Foo } from "./some-file"; +import { Observable } from "rxjs"; +import { map } from "rxjs/operators"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'hero'; +export const protobufPackage = "hero"; export interface HeroById { id: number; @@ -55,9 +55,7 @@ export const HeroById = { }, fromJSON(object: any): HeroById { - return { - id: isSet(object.id) ? Number(object.id) : 0, - }; + return { id: isSet(object.id) ? Number(object.id) : 0 }; }, toJSON(message: HeroById): unknown { @@ -104,9 +102,7 @@ export const VillainById = { }, fromJSON(object: any): VillainById { - return { - id: isSet(object.id) ? Number(object.id) : 0, - }; + return { id: isSet(object.id) ? Number(object.id) : 0 }; }, toJSON(message: VillainById): unknown { @@ -123,7 +119,7 @@ export const VillainById = { }; function createBaseHero(): Hero { - return { id: 0, name: '' }; + return { id: 0, name: "" }; } export const Hero = { @@ -131,7 +127,7 @@ export const Hero = { if (message.id !== 0) { writer.uint32(8).int32(message.id); } - if (message.name !== '') { + if (message.name !== "") { writer.uint32(18).string(message.name); } return writer; @@ -159,10 +155,7 @@ export const Hero = { }, fromJSON(object: any): Hero { - return { - id: isSet(object.id) ? Number(object.id) : 0, - name: isSet(object.name) ? String(object.name) : '', - }; + return { id: isSet(object.id) ? Number(object.id) : 0, name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Hero): unknown { @@ -175,13 +168,13 @@ export const Hero = { fromPartial, I>>(object: I): Hero { const message = createBaseHero(); message.id = object.id ?? 0; - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; function createBaseVillain(): Villain { - return { id: 0, name: '' }; + return { id: 0, name: "" }; } export const Villain = { @@ -189,7 +182,7 @@ export const Villain = { if (message.id !== 0) { writer.uint32(8).int32(message.id); } - if (message.name !== '') { + if (message.name !== "") { writer.uint32(18).string(message.name); } return writer; @@ -217,10 +210,7 @@ export const Villain = { }, fromJSON(object: any): Villain { - return { - id: isSet(object.id) ? Number(object.id) : 0, - name: isSet(object.name) ? String(object.name) : '', - }; + return { id: isSet(object.id) ? Number(object.id) : 0, name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Villain): unknown { @@ -233,7 +223,7 @@ export const Villain = { fromPartial, I>>(object: I): Villain { const message = createBaseVillain(); message.id = object.id ?? 0; - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; @@ -254,30 +244,30 @@ export class HeroServiceClientImpl implements HeroService { } FindOneHero(request: HeroById): Promise { const data = HeroById.encode(request).finish(); - const promise = this.rpc.request('hero.HeroService', 'FindOneHero', data); + const promise = this.rpc.request("hero.HeroService", "FindOneHero", data); return promise.then((data) => Hero.decode(new _m0.Reader(data))); } FindOneVillain(request: VillainById): Promise { const data = VillainById.encode(request).finish(); - const promise = this.rpc.request('hero.HeroService', 'FindOneVillain', data); + const promise = this.rpc.request("hero.HeroService", "FindOneVillain", data); return promise.then((data) => Villain.decode(new _m0.Reader(data))); } FindManyVillain(request: Observable): Observable { const data = request.pipe(map((request) => VillainById.encode(request).finish())); - const result = this.rpc.bidirectionalStreamingRequest('hero.HeroService', 'FindManyVillain', data); + const result = this.rpc.bidirectionalStreamingRequest("hero.HeroService", "FindManyVillain", data); return result.pipe(map((data) => Villain.decode(new _m0.Reader(data)))); } } export type HeroServiceDefinition = typeof HeroServiceDefinition; export const HeroServiceDefinition = { - name: 'HeroService', - fullName: 'hero.HeroService', + name: "HeroService", + fullName: "hero.HeroService", methods: { findOneHero: { - name: 'FindOneHero', + name: "FindOneHero", requestType: HeroById, requestStream: false, responseType: Hero, @@ -285,7 +275,7 @@ export const HeroServiceDefinition = { options: {}, }, findOneVillain: { - name: 'FindOneVillain', + name: "FindOneVillain", requestType: VillainById, requestStream: false, responseType: Villain, @@ -293,7 +283,7 @@ export const HeroServiceDefinition = { options: {}, }, findManyVillain: { - name: 'FindManyVillain', + name: "FindManyVillain", requestType: VillainById, requestStream: true, responseType: Villain, @@ -312,19 +302,13 @@ interface Rpc { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/generic-service-definitions-and-services/simple.ts b/integration/generic-service-definitions-and-services/simple.ts index b1e8795b6..7e3c5d5a0 100644 --- a/integration/generic-service-definitions-and-services/simple.ts +++ b/integration/generic-service-definitions-and-services/simple.ts @@ -1,19 +1,19 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface TestMessage { value: string; } function createBaseTestMessage(): TestMessage { - return { value: '' }; + return { value: "" }; } export const TestMessage = { encode(message: TestMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -38,9 +38,7 @@ export const TestMessage = { }, fromJSON(object: any): TestMessage { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: TestMessage): unknown { @@ -51,7 +49,7 @@ export const TestMessage = { fromPartial, I>>(object: I): TestMessage { const message = createBaseTestMessage(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -59,11 +57,11 @@ export const TestMessage = { /** @deprecated */ export type TestDefinition = typeof TestDefinition; export const TestDefinition = { - name: 'Test', - fullName: 'simple.Test', + name: "Test", + fullName: "simple.Test", methods: { unary: { - name: 'Unary', + name: "Unary", requestType: TestMessage, requestStream: false, responseType: TestMessage, @@ -71,7 +69,7 @@ export const TestDefinition = { options: {}, }, serverStreaming: { - name: 'ServerStreaming', + name: "ServerStreaming", requestType: TestMessage, requestStream: false, responseType: TestMessage, @@ -79,7 +77,7 @@ export const TestDefinition = { options: {}, }, clientStreaming: { - name: 'ClientStreaming', + name: "ClientStreaming", requestType: TestMessage, requestStream: true, responseType: TestMessage, @@ -87,7 +85,7 @@ export const TestDefinition = { options: {}, }, bidiStreaming: { - name: 'BidiStreaming', + name: "BidiStreaming", requestType: TestMessage, requestStream: true, responseType: TestMessage, @@ -96,7 +94,7 @@ export const TestDefinition = { }, /** @deprecated */ deprecated: { - name: 'Deprecated', + name: "Deprecated", requestType: TestMessage, requestStream: false, responseType: TestMessage, @@ -104,43 +102,33 @@ export const TestDefinition = { options: {}, }, idempotent: { - name: 'Idempotent', + name: "Idempotent", requestType: TestMessage, requestStream: false, responseType: TestMessage, responseStream: false, - options: { - idempotencyLevel: 'IDEMPOTENT', - }, + options: { idempotencyLevel: "IDEMPOTENT" }, }, noSideEffects: { - name: 'NoSideEffects', + name: "NoSideEffects", requestType: TestMessage, requestStream: false, responseType: TestMessage, responseStream: false, - options: { - idempotencyLevel: 'NO_SIDE_EFFECTS', - }, + options: { idempotencyLevel: "NO_SIDE_EFFECTS" }, }, }, } as const; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/generic-service-definitions/simple.ts b/integration/generic-service-definitions/simple.ts index b1e8795b6..7e3c5d5a0 100644 --- a/integration/generic-service-definitions/simple.ts +++ b/integration/generic-service-definitions/simple.ts @@ -1,19 +1,19 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface TestMessage { value: string; } function createBaseTestMessage(): TestMessage { - return { value: '' }; + return { value: "" }; } export const TestMessage = { encode(message: TestMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -38,9 +38,7 @@ export const TestMessage = { }, fromJSON(object: any): TestMessage { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: TestMessage): unknown { @@ -51,7 +49,7 @@ export const TestMessage = { fromPartial, I>>(object: I): TestMessage { const message = createBaseTestMessage(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -59,11 +57,11 @@ export const TestMessage = { /** @deprecated */ export type TestDefinition = typeof TestDefinition; export const TestDefinition = { - name: 'Test', - fullName: 'simple.Test', + name: "Test", + fullName: "simple.Test", methods: { unary: { - name: 'Unary', + name: "Unary", requestType: TestMessage, requestStream: false, responseType: TestMessage, @@ -71,7 +69,7 @@ export const TestDefinition = { options: {}, }, serverStreaming: { - name: 'ServerStreaming', + name: "ServerStreaming", requestType: TestMessage, requestStream: false, responseType: TestMessage, @@ -79,7 +77,7 @@ export const TestDefinition = { options: {}, }, clientStreaming: { - name: 'ClientStreaming', + name: "ClientStreaming", requestType: TestMessage, requestStream: true, responseType: TestMessage, @@ -87,7 +85,7 @@ export const TestDefinition = { options: {}, }, bidiStreaming: { - name: 'BidiStreaming', + name: "BidiStreaming", requestType: TestMessage, requestStream: true, responseType: TestMessage, @@ -96,7 +94,7 @@ export const TestDefinition = { }, /** @deprecated */ deprecated: { - name: 'Deprecated', + name: "Deprecated", requestType: TestMessage, requestStream: false, responseType: TestMessage, @@ -104,43 +102,33 @@ export const TestDefinition = { options: {}, }, idempotent: { - name: 'Idempotent', + name: "Idempotent", requestType: TestMessage, requestStream: false, responseType: TestMessage, responseStream: false, - options: { - idempotencyLevel: 'IDEMPOTENT', - }, + options: { idempotencyLevel: "IDEMPOTENT" }, }, noSideEffects: { - name: 'NoSideEffects', + name: "NoSideEffects", requestType: TestMessage, requestStream: false, responseType: TestMessage, responseStream: false, - options: { - idempotencyLevel: 'NO_SIDE_EFFECTS', - }, + options: { idempotencyLevel: "NO_SIDE_EFFECTS" }, }, }, } as const; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/global-this/global-this.ts b/integration/global-this/global-this.ts index 38d9eb5ed..3473114c2 100644 --- a/integration/global-this/global-this.ts +++ b/integration/global-this/global-this.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface Object { name: string; @@ -12,12 +12,12 @@ export interface Error { } function createBaseObject(): Object { - return { name: '' }; + return { name: "" }; } export const Object = { encode(message: Object, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -42,9 +42,7 @@ export const Object = { }, fromJSON(object: any): Object { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Object): unknown { @@ -55,18 +53,18 @@ export const Object = { fromPartial, I>>(object: I): Object { const message = createBaseObject(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; function createBaseError(): Error { - return { name: '' }; + return { name: "" }; } export const Error = { encode(message: Error, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -91,9 +89,7 @@ export const Error = { }, fromJSON(object: any): Error { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Error): unknown { @@ -104,26 +100,20 @@ export const Error = { fromPartial, I>>(object: I): Error { const message = createBaseError(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/grpc-js/google/protobuf/empty.ts b/integration/grpc-js/google/protobuf/empty.ts index 4e15078f1..4318905c6 100644 --- a/integration/grpc-js/google/protobuf/empty.ts +++ b/integration/grpc-js/google/protobuf/empty.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A generic empty message that you can re-use to avoid defining duplicated @@ -14,7 +14,8 @@ export const protobufPackage = 'google.protobuf'; * * The JSON representation for `Empty` is empty JSON object `{}`. */ -export interface Empty {} +export interface Empty { +} function createBaseEmpty(): Empty { return {}; @@ -57,17 +58,11 @@ export const Empty = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; diff --git a/integration/grpc-js/google/protobuf/struct.ts b/integration/grpc-js/google/protobuf/struct.ts index b764acb36..80a98258e 100644 --- a/integration/grpc-js/google/protobuf/struct.ts +++ b/integration/grpc-js/google/protobuf/struct.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the @@ -18,10 +18,10 @@ export enum NullValue { export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: - case 'NULL_VALUE': + case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } @@ -30,10 +30,10 @@ export function nullValueFromJSON(object: any): NullValue { export function nullValueToJSON(object: NullValue): string { switch (object) { case NullValue.NULL_VALUE: - return 'NULL_VALUE'; + return "NULL_VALUE"; case NullValue.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -67,15 +67,25 @@ export interface Struct_FieldsEntry { */ export interface Value { /** Represents a null value. */ - nullValue: NullValue | undefined; + nullValue: + | NullValue + | undefined; /** Represents a double value. */ - numberValue: number | undefined; + numberValue: + | number + | undefined; /** Represents a string value. */ - stringValue: string | undefined; + stringValue: + | string + | undefined; /** Represents a boolean value. */ - boolValue: boolean | undefined; + boolValue: + | boolean + | undefined; /** Represents a structured value. */ - structValue: { [key: string]: any } | undefined; + structValue: + | { [key: string]: any } + | undefined; /** Represents a repeated `Value`. */ listValue: Array | undefined; } @@ -129,9 +139,9 @@ export const 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; - }, {}) + acc[key] = value as any | undefined; + return acc; + }, {}) : {}, }; }, @@ -156,7 +166,7 @@ export const Struct = { } return acc; }, - {} + {}, ); return message; }, @@ -181,12 +191,12 @@ export const Struct = { }; function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Struct_FieldsEntry = { encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -217,10 +227,7 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object?.value) ? object.value : undefined, - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -232,7 +239,7 @@ export const Struct_FieldsEntry = { fromPartial, I>>(object: I): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -344,18 +351,18 @@ export const Value = { if (value === null) { result.nullValue = NullValue.NULL_VALUE; - } else if (typeof value === 'boolean') { + } else if (typeof value === "boolean") { result.boolValue = value; - } else if (typeof value === 'number') { + } else if (typeof value === "number") { result.numberValue = value; - } else if (typeof value === 'string') { + } else if (typeof value === "string") { result.stringValue = value; } else if (Array.isArray(value)) { result.listValue = value; - } else if (typeof value === 'object') { + } else if (typeof value === "object") { result.structValue = value; - } else if (typeof value !== 'undefined') { - throw new Error('Unsupported any value type: ' + typeof value); + } else if (typeof value !== "undefined") { + throw new Error("Unsupported any value type: " + typeof value); } return result; @@ -410,9 +417,7 @@ export const ListValue = { }, fromJSON(object: any): ListValue { - return { - values: Array.isArray(object?.values) ? [...object.values] : [], - }; + return { values: Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { @@ -446,23 +451,17 @@ export const 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/grpc-js/google/protobuf/timestamp.ts b/integration/grpc-js/google/protobuf/timestamp.ts index c52fb2549..5497f7183 100644 --- a/integration/grpc-js/google/protobuf/timestamp.ts +++ b/integration/grpc-js/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/grpc-js/google/protobuf/wrappers.ts b/integration/grpc-js/google/protobuf/wrappers.ts index 5e90fd4da..3145298cb 100644 --- a/integration/grpc-js/google/protobuf/wrappers.ts +++ b/integration/grpc-js/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial, I>>(object: I): StringValue { const message = createBaseStringValue(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), - }; + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,36 +552,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/grpc-js/simple.ts b/integration/grpc-js/simple.ts index c4ebda089..1dc515b05 100644 --- a/integration/grpc-js/simple.ts +++ b/integration/grpc-js/simple.ts @@ -1,39 +1,39 @@ /* eslint-disable */ import { - makeGenericClientConstructor, + CallOptions, ChannelCredentials, ChannelOptions, - UntypedServiceImplementation, - handleUnaryCall, - handleServerStreamingCall, - handleClientStreamingCall, - handleBidiStreamingCall, Client, - ClientUnaryCall, - Metadata, - CallOptions, + ClientDuplexStream, ClientReadableStream, + ClientUnaryCall, ClientWritableStream, - ClientDuplexStream, + handleBidiStreamingCall, + handleClientStreamingCall, + handleServerStreamingCall, + handleUnaryCall, + makeGenericClientConstructor, + Metadata, ServiceError, -} from '@grpc/grpc-js'; -import { Timestamp } from './google/protobuf/timestamp'; -import { Empty } from './google/protobuf/empty'; + UntypedServiceImplementation, +} from "@grpc/grpc-js"; +import { Timestamp } from "./google/protobuf/timestamp"; +import { Empty } from "./google/protobuf/empty"; import { - StringValue, - Int64Value, - UInt64Value, - Int32Value, - UInt32Value, + BoolValue, BytesValue, - FloatValue, DoubleValue, - BoolValue, -} from './google/protobuf/wrappers'; -import { Struct, ListValue, Value } from './google/protobuf/struct'; -import * as _m0 from 'protobufjs/minimal'; + FloatValue, + Int32Value, + Int64Value, + StringValue, + UInt32Value, + UInt64Value, +} from "./google/protobuf/wrappers"; +import { ListValue, Struct, Value } from "./google/protobuf/struct"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface TestMessage { timestamp: Date | undefined; @@ -70,9 +70,7 @@ export const TestMessage = { }, fromJSON(object: any): TestMessage { - return { - timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, - }; + return { timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined }; }, toJSON(message: TestMessage): unknown { @@ -101,7 +99,7 @@ export const TestService = { * @deprecated */ unary: { - path: '/simple.Test/Unary', + path: "/simple.Test/Unary", requestStream: false, responseStream: false, requestSerialize: (value: Empty) => Buffer.from(Empty.encode(value).finish()), @@ -110,16 +108,16 @@ export const TestService = { responseDeserialize: (value: Buffer) => Empty.decode(value), }, unaryStringValue: { - path: '/simple.Test/UnaryStringValue', + path: "/simple.Test/UnaryStringValue", requestStream: false, responseStream: false, - requestSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? '' }).finish()), + requestSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? "" }).finish()), requestDeserialize: (value: Buffer) => StringValue.decode(value).value, - responseSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? '' }).finish()), + responseSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? "" }).finish()), responseDeserialize: (value: Buffer) => StringValue.decode(value).value, }, unaryInt64Value: { - path: '/simple.Test/UnaryInt64Value', + path: "/simple.Test/UnaryInt64Value", requestStream: false, responseStream: false, requestSerialize: (value: number | undefined) => Buffer.from(Int64Value.encode({ value: value ?? 0 }).finish()), @@ -128,7 +126,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => Int64Value.decode(value).value, }, unaryUint64Value: { - path: '/simple.Test/UnaryUint64Value', + path: "/simple.Test/UnaryUint64Value", requestStream: false, responseStream: false, requestSerialize: (value: number | undefined) => Buffer.from(UInt64Value.encode({ value: value ?? 0 }).finish()), @@ -137,7 +135,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => UInt64Value.decode(value).value, }, unaryInt32Value: { - path: '/simple.Test/UnaryInt32Value', + path: "/simple.Test/UnaryInt32Value", requestStream: false, responseStream: false, requestSerialize: (value: number | undefined) => Buffer.from(Int32Value.encode({ value: value ?? 0 }).finish()), @@ -146,7 +144,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => Int32Value.decode(value).value, }, unaryUInt32Value: { - path: '/simple.Test/UnaryUInt32Value', + path: "/simple.Test/UnaryUInt32Value", requestStream: false, responseStream: false, requestSerialize: (value: number | undefined) => Buffer.from(UInt32Value.encode({ value: value ?? 0 }).finish()), @@ -155,7 +153,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => UInt32Value.decode(value).value, }, unaryBytesValue: { - path: '/simple.Test/UnaryBytesValue', + path: "/simple.Test/UnaryBytesValue", requestStream: false, responseStream: false, requestSerialize: (value: Uint8Array | undefined) => @@ -166,7 +164,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => BytesValue.decode(value).value, }, unaryFloatValue: { - path: '/simple.Test/UnaryFloatValue', + path: "/simple.Test/UnaryFloatValue", requestStream: false, responseStream: false, requestSerialize: (value: number | undefined) => Buffer.from(FloatValue.encode({ value: value ?? 0 }).finish()), @@ -175,7 +173,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => FloatValue.decode(value).value, }, unaryDoubleValue: { - path: '/simple.Test/UnaryDoubleValue', + path: "/simple.Test/UnaryDoubleValue", requestStream: false, responseStream: false, requestSerialize: (value: number | undefined) => Buffer.from(DoubleValue.encode({ value: value ?? 0 }).finish()), @@ -184,7 +182,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => DoubleValue.decode(value).value, }, unaryBoolValue: { - path: '/simple.Test/UnaryBoolValue', + path: "/simple.Test/UnaryBoolValue", requestStream: false, responseStream: false, requestSerialize: (value: boolean | undefined) => Buffer.from(BoolValue.encode({ value: value ?? false }).finish()), @@ -194,7 +192,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => BoolValue.decode(value).value, }, unaryTimestamp: { - path: '/simple.Test/UnaryTimestamp', + path: "/simple.Test/UnaryTimestamp", requestStream: false, responseStream: false, requestSerialize: (value: Date) => Buffer.from(Timestamp.encode(toTimestamp(value)).finish()), @@ -203,7 +201,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => Timestamp.decode(value), }, struct: { - path: '/simple.Test/Struct', + path: "/simple.Test/Struct", requestStream: false, responseStream: false, requestSerialize: (value: { [key: string]: any } | undefined) => @@ -214,7 +212,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => Struct.unwrap(Struct.decode(value)), }, value: { - path: '/simple.Test/Value', + path: "/simple.Test/Value", requestStream: false, responseStream: false, requestSerialize: (value: any | undefined) => Buffer.from(Value.encode(value).finish()), @@ -223,7 +221,7 @@ export const TestService = { responseDeserialize: (value: Buffer) => Value.decode(value), }, listValue: { - path: '/simple.Test/ListValue', + path: "/simple.Test/ListValue", requestStream: false, responseStream: false, requestSerialize: (value: Array | undefined) => @@ -235,7 +233,7 @@ export const TestService = { }, /** Server Streaming */ serverStreaming: { - path: '/simple.Test/ServerStreaming', + path: "/simple.Test/ServerStreaming", requestStream: false, responseStream: true, requestSerialize: (value: TestMessage) => Buffer.from(TestMessage.encode(value).finish()), @@ -244,16 +242,16 @@ export const TestService = { responseDeserialize: (value: Buffer) => TestMessage.decode(value), }, serverStreamingStringValue: { - path: '/simple.Test/ServerStreamingStringValue', + path: "/simple.Test/ServerStreamingStringValue", requestStream: false, responseStream: true, - requestSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? '' }).finish()), + requestSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? "" }).finish()), requestDeserialize: (value: Buffer) => StringValue.decode(value).value, - responseSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? '' }).finish()), + responseSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? "" }).finish()), responseDeserialize: (value: Buffer) => StringValue.decode(value).value, }, serverStreamingStruct: { - path: '/simple.Test/ServerStreamingStruct', + path: "/simple.Test/ServerStreamingStruct", requestStream: false, responseStream: true, requestSerialize: (value: { [key: string]: any } | undefined) => @@ -265,7 +263,7 @@ export const TestService = { }, /** Client Streaming */ clientStreaming: { - path: '/simple.Test/ClientStreaming', + path: "/simple.Test/ClientStreaming", requestStream: true, responseStream: false, requestSerialize: (value: TestMessage) => Buffer.from(TestMessage.encode(value).finish()), @@ -274,17 +272,17 @@ export const TestService = { responseDeserialize: (value: Buffer) => TestMessage.decode(value), }, clientStreamingStringValue: { - path: '/simple.Test/ClientStreamingStringValue', + path: "/simple.Test/ClientStreamingStringValue", requestStream: true, responseStream: false, - requestSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? '' }).finish()), + requestSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? "" }).finish()), requestDeserialize: (value: Buffer) => StringValue.decode(value).value, - responseSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? '' }).finish()), + responseSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? "" }).finish()), responseDeserialize: (value: Buffer) => StringValue.decode(value).value, }, /** Bidi Streaming */ bidiStreaming: { - path: '/simple.Test/BidiStreaming', + path: "/simple.Test/BidiStreaming", requestStream: true, responseStream: true, requestSerialize: (value: TestMessage) => Buffer.from(TestMessage.encode(value).finish()), @@ -293,12 +291,12 @@ export const TestService = { responseDeserialize: (value: Buffer) => TestMessage.decode(value), }, bidiStreamingStringValue: { - path: '/simple.Test/BidiStreamingStringValue', + path: "/simple.Test/BidiStreamingStringValue", requestStream: true, responseStream: true, - requestSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? '' }).finish()), + requestSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? "" }).finish()), requestDeserialize: (value: Buffer) => StringValue.decode(value).value, - responseSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? '' }).finish()), + responseSerialize: (value: string | undefined) => Buffer.from(StringValue.encode({ value: value ?? "" }).finish()), responseDeserialize: (value: Buffer) => StringValue.decode(value).value, }, } as const; @@ -348,263 +346,263 @@ export interface TestClient extends Client { unary( request: Empty, metadata: Metadata, - callback: (error: ServiceError | null, response: Empty) => void + callback: (error: ServiceError | null, response: Empty) => void, ): ClientUnaryCall; unary( request: Empty, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Empty) => void + callback: (error: ServiceError | null, response: Empty) => void, ): ClientUnaryCall; unaryStringValue( request: string | undefined, - callback: (error: ServiceError | null, response: string | undefined) => void + callback: (error: ServiceError | null, response: string | undefined) => void, ): ClientUnaryCall; unaryStringValue( request: string | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: string | undefined) => void + callback: (error: ServiceError | null, response: string | undefined) => void, ): ClientUnaryCall; unaryStringValue( request: string | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: string | undefined) => void + callback: (error: ServiceError | null, response: string | undefined) => void, ): ClientUnaryCall; unaryInt64Value( request: number | undefined, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryInt64Value( request: number | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryInt64Value( request: number | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryUint64Value( request: number | undefined, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryUint64Value( request: number | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryUint64Value( request: number | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryInt32Value( request: number | undefined, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryInt32Value( request: number | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryInt32Value( request: number | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryUInt32Value( request: number | undefined, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryUInt32Value( request: number | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryUInt32Value( request: number | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryBytesValue( request: Uint8Array | undefined, - callback: (error: ServiceError | null, response: Uint8Array | undefined) => void + callback: (error: ServiceError | null, response: Uint8Array | undefined) => void, ): ClientUnaryCall; unaryBytesValue( request: Uint8Array | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: Uint8Array | undefined) => void + callback: (error: ServiceError | null, response: Uint8Array | undefined) => void, ): ClientUnaryCall; unaryBytesValue( request: Uint8Array | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Uint8Array | undefined) => void + callback: (error: ServiceError | null, response: Uint8Array | undefined) => void, ): ClientUnaryCall; unaryFloatValue( request: number | undefined, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryFloatValue( request: number | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryFloatValue( request: number | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryDoubleValue( request: number | undefined, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryDoubleValue( request: number | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryDoubleValue( request: number | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: number | undefined) => void + callback: (error: ServiceError | null, response: number | undefined) => void, ): ClientUnaryCall; unaryBoolValue( request: boolean | undefined, - callback: (error: ServiceError | null, response: boolean | undefined) => void + callback: (error: ServiceError | null, response: boolean | undefined) => void, ): ClientUnaryCall; unaryBoolValue( request: boolean | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: boolean | undefined) => void + callback: (error: ServiceError | null, response: boolean | undefined) => void, ): ClientUnaryCall; unaryBoolValue( request: boolean | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: boolean | undefined) => void + callback: (error: ServiceError | null, response: boolean | undefined) => void, ): ClientUnaryCall; unaryTimestamp(request: Date, callback: (error: ServiceError | null, response: Date) => void): ClientUnaryCall; unaryTimestamp( request: Date, metadata: Metadata, - callback: (error: ServiceError | null, response: Date) => void + callback: (error: ServiceError | null, response: Date) => void, ): ClientUnaryCall; unaryTimestamp( request: Date, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Date) => void + callback: (error: ServiceError | null, response: Date) => void, ): ClientUnaryCall; struct( request: { [key: string]: any } | undefined, - callback: (error: ServiceError | null, response: { [key: string]: any } | undefined) => void + callback: (error: ServiceError | null, response: { [key: string]: any } | undefined) => void, ): ClientUnaryCall; struct( request: { [key: string]: any } | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: { [key: string]: any } | undefined) => void + callback: (error: ServiceError | null, response: { [key: string]: any } | undefined) => void, ): ClientUnaryCall; struct( request: { [key: string]: any } | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: { [key: string]: any } | undefined) => void + callback: (error: ServiceError | null, response: { [key: string]: any } | undefined) => void, ): ClientUnaryCall; value( request: any | undefined, - callback: (error: ServiceError | null, response: any | undefined) => void + callback: (error: ServiceError | null, response: any | undefined) => void, ): ClientUnaryCall; value( request: any | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: any | undefined) => void + callback: (error: ServiceError | null, response: any | undefined) => void, ): ClientUnaryCall; value( request: any | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: any | undefined) => void + callback: (error: ServiceError | null, response: any | undefined) => void, ): ClientUnaryCall; listValue( request: Array | undefined, - callback: (error: ServiceError | null, response: Array | undefined) => void + callback: (error: ServiceError | null, response: Array | undefined) => void, ): ClientUnaryCall; listValue( request: Array | undefined, metadata: Metadata, - callback: (error: ServiceError | null, response: Array | undefined) => void + callback: (error: ServiceError | null, response: Array | undefined) => void, ): ClientUnaryCall; listValue( request: Array | undefined, metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: Array | undefined) => void + callback: (error: ServiceError | null, response: Array | undefined) => void, ): ClientUnaryCall; /** Server Streaming */ serverStreaming(request: TestMessage, options?: Partial): ClientReadableStream; serverStreaming( request: TestMessage, metadata?: Metadata, - options?: Partial + options?: Partial, ): ClientReadableStream; serverStreamingStringValue( request: string | undefined, - options?: Partial + options?: Partial, ): ClientReadableStream; serverStreamingStringValue( request: string | undefined, metadata?: Metadata, - options?: Partial + options?: Partial, ): ClientReadableStream; serverStreamingStruct( request: { [key: string]: any } | undefined, - options?: Partial + options?: Partial, ): ClientReadableStream<{ [key: string]: any } | undefined>; serverStreamingStruct( request: { [key: string]: any } | undefined, metadata?: Metadata, - options?: Partial + options?: Partial, ): ClientReadableStream<{ [key: string]: any } | undefined>; /** Client Streaming */ clientStreaming( - callback: (error: ServiceError | null, response: TestMessage) => void + callback: (error: ServiceError | null, response: TestMessage) => void, ): ClientWritableStream; clientStreaming( metadata: Metadata, - callback: (error: ServiceError | null, response: TestMessage) => void + callback: (error: ServiceError | null, response: TestMessage) => void, ): ClientWritableStream; clientStreaming( options: Partial, - callback: (error: ServiceError | null, response: TestMessage) => void + callback: (error: ServiceError | null, response: TestMessage) => void, ): ClientWritableStream; clientStreaming( metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: TestMessage) => void + callback: (error: ServiceError | null, response: TestMessage) => void, ): ClientWritableStream; clientStreamingStringValue( - callback: (error: ServiceError | null, response: string | undefined) => void + callback: (error: ServiceError | null, response: string | undefined) => void, ): ClientWritableStream; clientStreamingStringValue( metadata: Metadata, - callback: (error: ServiceError | null, response: string | undefined) => void + callback: (error: ServiceError | null, response: string | undefined) => void, ): ClientWritableStream; clientStreamingStringValue( options: Partial, - callback: (error: ServiceError | null, response: string | undefined) => void + callback: (error: ServiceError | null, response: string | undefined) => void, ): ClientWritableStream; clientStreamingStringValue( metadata: Metadata, options: Partial, - callback: (error: ServiceError | null, response: string | undefined) => void + callback: (error: ServiceError | null, response: string | undefined) => void, ): ClientWritableStream; /** Bidi Streaming */ bidiStreaming(): ClientDuplexStream; @@ -614,30 +612,24 @@ export interface TestClient extends Client { bidiStreamingStringValue(options: Partial): ClientDuplexStream; bidiStreamingStringValue( metadata: Metadata, - options?: Partial + options?: Partial, ): ClientDuplexStream; } -export const TestClient = makeGenericClientConstructor(TestService, 'simple.Test') as unknown as { +export const TestClient = makeGenericClientConstructor(TestService, "simple.Test") as unknown as { new (address: string, credentials: ChannelCredentials, options?: Partial): TestClient; service: typeof TestService; }; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -655,7 +647,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/grpc-web-go-server/example.ts b/integration/grpc-web-go-server/example.ts index 020488699..cf3e9f63d 100644 --- a/integration/grpc-web-go-server/example.ts +++ b/integration/grpc-web-go-server/example.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import * as _m0 from 'protobufjs/minimal'; +import { Observable } from "rxjs"; +import { map } from "rxjs/operators"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'rpx'; +export const protobufPackage = "rpx"; export interface DashFlash { msg: string; @@ -21,19 +21,19 @@ export enum DashFlash_Type { export function dashFlash_TypeFromJSON(object: any): DashFlash_Type { switch (object) { case 0: - case 'Undefined': + case "Undefined": return DashFlash_Type.Undefined; case 1: - case 'Success': + case "Success": return DashFlash_Type.Success; case 2: - case 'Warn': + case "Warn": return DashFlash_Type.Warn; case 3: - case 'Error': + case "Error": return DashFlash_Type.Error; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return DashFlash_Type.UNRECOGNIZED; } @@ -42,16 +42,16 @@ export function dashFlash_TypeFromJSON(object: any): DashFlash_Type { export function dashFlash_TypeToJSON(object: DashFlash_Type): string { switch (object) { case DashFlash_Type.Undefined: - return 'Undefined'; + return "Undefined"; case DashFlash_Type.Success: - return 'Success'; + return "Success"; case DashFlash_Type.Warn: - return 'Warn'; + return "Warn"; case DashFlash_Type.Error: - return 'Error'; + return "Error"; case DashFlash_Type.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -90,15 +90,16 @@ export interface DashAPICredsDeleteReq { id: string; } -export interface Empty {} +export interface Empty { +} function createBaseDashFlash(): DashFlash { - return { msg: '', type: 0 }; + return { msg: "", type: 0 }; } export const DashFlash = { encode(message: DashFlash, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.msg !== '') { + if (message.msg !== "") { writer.uint32(10).string(message.msg); } if (message.type !== 0) { @@ -130,7 +131,7 @@ export const DashFlash = { fromJSON(object: any): DashFlash { return { - msg: isSet(object.msg) ? String(object.msg) : '', + msg: isSet(object.msg) ? String(object.msg) : "", type: isSet(object.type) ? dashFlash_TypeFromJSON(object.type) : 0, }; }, @@ -144,19 +145,19 @@ export const DashFlash = { fromPartial, I>>(object: I): DashFlash { const message = createBaseDashFlash(); - message.msg = object.msg ?? ''; + message.msg = object.msg ?? ""; message.type = object.type ?? 0; return message; }, }; function createBaseDashUserSettingsState(): DashUserSettingsState { - return { email: '', urls: undefined, flashes: [] }; + return { email: "", urls: undefined, flashes: [] }; } export const DashUserSettingsState = { encode(message: DashUserSettingsState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.email !== '') { + if (message.email !== "") { writer.uint32(10).string(message.email); } if (message.urls !== undefined) { @@ -194,7 +195,7 @@ export const DashUserSettingsState = { fromJSON(object: any): DashUserSettingsState { return { - email: isSet(object.email) ? String(object.email) : '', + email: isSet(object.email) ? String(object.email) : "", urls: isSet(object.urls) ? DashUserSettingsState_URLs.fromJSON(object.urls) : undefined, flashes: Array.isArray(object?.flashes) ? object.flashes.map((e: any) => DashFlash.fromJSON(e)) : [], }; @@ -206,7 +207,7 @@ export const DashUserSettingsState = { message.urls !== undefined && (obj.urls = message.urls ? DashUserSettingsState_URLs.toJSON(message.urls) : undefined); if (message.flashes) { - obj.flashes = message.flashes.map((e) => (e ? DashFlash.toJSON(e) : undefined)); + obj.flashes = message.flashes.map((e) => e ? DashFlash.toJSON(e) : undefined); } else { obj.flashes = []; } @@ -215,26 +216,25 @@ export const DashUserSettingsState = { fromPartial, I>>(object: I): DashUserSettingsState { const message = createBaseDashUserSettingsState(); - message.email = object.email ?? ''; - message.urls = - object.urls !== undefined && object.urls !== null - ? DashUserSettingsState_URLs.fromPartial(object.urls) - : undefined; + message.email = object.email ?? ""; + message.urls = (object.urls !== undefined && object.urls !== null) + ? DashUserSettingsState_URLs.fromPartial(object.urls) + : undefined; message.flashes = object.flashes?.map((e) => DashFlash.fromPartial(e)) || []; return message; }, }; function createBaseDashUserSettingsState_URLs(): DashUserSettingsState_URLs { - return { connectGoogle: '', connectGithub: '' }; + return { connectGoogle: "", connectGithub: "" }; } export const DashUserSettingsState_URLs = { encode(message: DashUserSettingsState_URLs, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.connectGoogle !== '') { + if (message.connectGoogle !== "") { writer.uint32(10).string(message.connectGoogle); } - if (message.connectGithub !== '') { + if (message.connectGithub !== "") { writer.uint32(18).string(message.connectGithub); } return writer; @@ -263,8 +263,8 @@ export const DashUserSettingsState_URLs = { fromJSON(object: any): DashUserSettingsState_URLs { return { - connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : '', - connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : '', + connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : "", + connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : "", }; }, @@ -277,28 +277,28 @@ export const DashUserSettingsState_URLs = { fromPartial, I>>(object: I): DashUserSettingsState_URLs { const message = createBaseDashUserSettingsState_URLs(); - message.connectGoogle = object.connectGoogle ?? ''; - message.connectGithub = object.connectGithub ?? ''; + message.connectGoogle = object.connectGoogle ?? ""; + message.connectGithub = object.connectGithub ?? ""; return message; }, }; function createBaseDashCred(): DashCred { - return { description: '', metadata: '', token: '', id: '' }; + return { description: "", metadata: "", token: "", id: "" }; } export const DashCred = { encode(message: DashCred, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.description !== '') { + if (message.description !== "") { writer.uint32(18).string(message.description); } - if (message.metadata !== '') { + if (message.metadata !== "") { writer.uint32(26).string(message.metadata); } - if (message.token !== '') { + if (message.token !== "") { writer.uint32(34).string(message.token); } - if (message.id !== '') { + if (message.id !== "") { writer.uint32(58).string(message.id); } return writer; @@ -333,10 +333,10 @@ export const DashCred = { fromJSON(object: any): DashCred { return { - description: isSet(object.description) ? String(object.description) : '', - metadata: isSet(object.metadata) ? String(object.metadata) : '', - token: isSet(object.token) ? String(object.token) : '', - id: isSet(object.id) ? String(object.id) : '', + description: isSet(object.description) ? String(object.description) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "", + token: isSet(object.token) ? String(object.token) : "", + id: isSet(object.id) ? String(object.id) : "", }; }, @@ -351,24 +351,24 @@ export const DashCred = { fromPartial, I>>(object: I): DashCred { const message = createBaseDashCred(); - message.description = object.description ?? ''; - message.metadata = object.metadata ?? ''; - message.token = object.token ?? ''; - message.id = object.id ?? ''; + message.description = object.description ?? ""; + message.metadata = object.metadata ?? ""; + message.token = object.token ?? ""; + message.id = object.id ?? ""; return message; }, }; function createBaseDashAPICredsCreateReq(): DashAPICredsCreateReq { - return { description: '', metadata: '' }; + return { description: "", metadata: "" }; } export const DashAPICredsCreateReq = { encode(message: DashAPICredsCreateReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.description !== '') { + if (message.description !== "") { writer.uint32(10).string(message.description); } - if (message.metadata !== '') { + if (message.metadata !== "") { writer.uint32(18).string(message.metadata); } return writer; @@ -397,8 +397,8 @@ export const DashAPICredsCreateReq = { fromJSON(object: any): DashAPICredsCreateReq { return { - description: isSet(object.description) ? String(object.description) : '', - metadata: isSet(object.metadata) ? String(object.metadata) : '', + description: isSet(object.description) ? String(object.description) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "", }; }, @@ -411,28 +411,28 @@ export const DashAPICredsCreateReq = { fromPartial, I>>(object: I): DashAPICredsCreateReq { const message = createBaseDashAPICredsCreateReq(); - message.description = object.description ?? ''; - message.metadata = object.metadata ?? ''; + message.description = object.description ?? ""; + message.metadata = object.metadata ?? ""; return message; }, }; function createBaseDashAPICredsUpdateReq(): DashAPICredsUpdateReq { - return { credSid: '', description: '', metadata: '', id: '' }; + return { credSid: "", description: "", metadata: "", id: "" }; } export const DashAPICredsUpdateReq = { encode(message: DashAPICredsUpdateReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.credSid !== '') { + if (message.credSid !== "") { writer.uint32(10).string(message.credSid); } - if (message.description !== '') { + if (message.description !== "") { writer.uint32(18).string(message.description); } - if (message.metadata !== '') { + if (message.metadata !== "") { writer.uint32(26).string(message.metadata); } - if (message.id !== '') { + if (message.id !== "") { writer.uint32(42).string(message.id); } return writer; @@ -467,10 +467,10 @@ export const DashAPICredsUpdateReq = { fromJSON(object: any): DashAPICredsUpdateReq { return { - credSid: isSet(object.credSid) ? String(object.credSid) : '', - description: isSet(object.description) ? String(object.description) : '', - metadata: isSet(object.metadata) ? String(object.metadata) : '', - id: isSet(object.id) ? String(object.id) : '', + credSid: isSet(object.credSid) ? String(object.credSid) : "", + description: isSet(object.description) ? String(object.description) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "", + id: isSet(object.id) ? String(object.id) : "", }; }, @@ -485,24 +485,24 @@ export const DashAPICredsUpdateReq = { fromPartial, I>>(object: I): DashAPICredsUpdateReq { const message = createBaseDashAPICredsUpdateReq(); - message.credSid = object.credSid ?? ''; - message.description = object.description ?? ''; - message.metadata = object.metadata ?? ''; - message.id = object.id ?? ''; + message.credSid = object.credSid ?? ""; + message.description = object.description ?? ""; + message.metadata = object.metadata ?? ""; + message.id = object.id ?? ""; return message; }, }; function createBaseDashAPICredsDeleteReq(): DashAPICredsDeleteReq { - return { credSid: '', id: '' }; + return { credSid: "", id: "" }; } export const DashAPICredsDeleteReq = { encode(message: DashAPICredsDeleteReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.credSid !== '') { + if (message.credSid !== "") { writer.uint32(10).string(message.credSid); } - if (message.id !== '') { + if (message.id !== "") { writer.uint32(26).string(message.id); } return writer; @@ -531,8 +531,8 @@ export const DashAPICredsDeleteReq = { fromJSON(object: any): DashAPICredsDeleteReq { return { - credSid: isSet(object.credSid) ? String(object.credSid) : '', - id: isSet(object.id) ? String(object.id) : '', + credSid: isSet(object.credSid) ? String(object.credSid) : "", + id: isSet(object.id) ? String(object.id) : "", }; }, @@ -545,8 +545,8 @@ export const DashAPICredsDeleteReq = { fromPartial, I>>(object: I): DashAPICredsDeleteReq { const message = createBaseDashAPICredsDeleteReq(); - message.credSid = object.credSid ?? ''; - message.id = object.id ?? ''; + message.credSid = object.credSid ?? ""; + message.id = object.id ?? ""; return message; }, }; @@ -604,13 +604,13 @@ export class DashStateClientImpl implements DashState { } UserSettings(request: Empty): Promise { const data = Empty.encode(request).finish(); - const promise = this.rpc.request('rpx.DashState', 'UserSettings', data); + const promise = this.rpc.request("rpx.DashState", "UserSettings", data); return promise.then((data) => DashUserSettingsState.decode(new _m0.Reader(data))); } ActiveUserSettingsStream(request: Empty): Observable { const data = Empty.encode(request).finish(); - const result = this.rpc.serverStreamingRequest('rpx.DashState', 'ActiveUserSettingsStream', data); + const result = this.rpc.serverStreamingRequest("rpx.DashState", "ActiveUserSettingsStream", data); return result.pipe(map((data) => DashUserSettingsState.decode(new _m0.Reader(data)))); } } @@ -636,19 +636,19 @@ export class DashAPICredsClientImpl implements DashAPICreds { } Create(request: DashAPICredsCreateReq): Promise { const data = DashAPICredsCreateReq.encode(request).finish(); - const promise = this.rpc.request('rpx.DashAPICreds', 'Create', data); + const promise = this.rpc.request("rpx.DashAPICreds", "Create", data); return promise.then((data) => DashCred.decode(new _m0.Reader(data))); } Update(request: DashAPICredsUpdateReq): Promise { const data = DashAPICredsUpdateReq.encode(request).finish(); - const promise = this.rpc.request('rpx.DashAPICreds', 'Update', data); + const promise = this.rpc.request("rpx.DashAPICreds", "Update", data); return promise.then((data) => DashCred.decode(new _m0.Reader(data))); } Delete(request: DashAPICredsDeleteReq): Promise { const data = DashAPICredsDeleteReq.encode(request).finish(); - const promise = this.rpc.request('rpx.DashAPICreds', 'Delete', data); + const promise = this.rpc.request("rpx.DashAPICreds", "Delete", data); return promise.then((data) => DashCred.decode(new _m0.Reader(data))); } } @@ -662,19 +662,13 @@ interface Rpc { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/grpc-web-no-streaming-observable/example.ts b/integration/grpc-web-no-streaming-observable/example.ts index bdb308776..5412e4eb0 100644 --- a/integration/grpc-web-no-streaming-observable/example.ts +++ b/integration/grpc-web-no-streaming-observable/example.ts @@ -1,11 +1,11 @@ /* eslint-disable */ -import { grpc } from '@improbable-eng/grpc-web'; -import { BrowserHeaders } from 'browser-headers'; -import { take } from 'rxjs/operators'; -import { Observable } from 'rxjs'; -import * as _m0 from 'protobufjs/minimal'; +import { grpc } from "@improbable-eng/grpc-web"; +import { BrowserHeaders } from "browser-headers"; +import { take } from "rxjs/operators"; +import { Observable } from "rxjs"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'rpx'; +export const protobufPackage = "rpx"; export interface DashFlash { msg: string; @@ -23,19 +23,19 @@ export enum DashFlash_Type { export function dashFlash_TypeFromJSON(object: any): DashFlash_Type { switch (object) { case 0: - case 'Undefined': + case "Undefined": return DashFlash_Type.Undefined; case 1: - case 'Success': + case "Success": return DashFlash_Type.Success; case 2: - case 'Warn': + case "Warn": return DashFlash_Type.Warn; case 3: - case 'Error': + case "Error": return DashFlash_Type.Error; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return DashFlash_Type.UNRECOGNIZED; } @@ -44,16 +44,16 @@ export function dashFlash_TypeFromJSON(object: any): DashFlash_Type { export function dashFlash_TypeToJSON(object: DashFlash_Type): string { switch (object) { case DashFlash_Type.Undefined: - return 'Undefined'; + return "Undefined"; case DashFlash_Type.Success: - return 'Success'; + return "Success"; case DashFlash_Type.Warn: - return 'Warn'; + return "Warn"; case DashFlash_Type.Error: - return 'Error'; + return "Error"; case DashFlash_Type.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -68,15 +68,16 @@ export interface DashUserSettingsState_URLs { connectGithub: string; } -export interface Empty {} +export interface Empty { +} function createBaseDashFlash(): DashFlash { - return { msg: '', type: 0 }; + return { msg: "", type: 0 }; } export const DashFlash = { encode(message: DashFlash, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.msg !== '') { + if (message.msg !== "") { writer.uint32(10).string(message.msg); } if (message.type !== 0) { @@ -108,7 +109,7 @@ export const DashFlash = { fromJSON(object: any): DashFlash { return { - msg: isSet(object.msg) ? String(object.msg) : '', + msg: isSet(object.msg) ? String(object.msg) : "", type: isSet(object.type) ? dashFlash_TypeFromJSON(object.type) : 0, }; }, @@ -122,19 +123,19 @@ export const DashFlash = { fromPartial, I>>(object: I): DashFlash { const message = createBaseDashFlash(); - message.msg = object.msg ?? ''; + message.msg = object.msg ?? ""; message.type = object.type ?? 0; return message; }, }; function createBaseDashUserSettingsState(): DashUserSettingsState { - return { email: '', urls: undefined, flashes: [] }; + return { email: "", urls: undefined, flashes: [] }; } export const DashUserSettingsState = { encode(message: DashUserSettingsState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.email !== '') { + if (message.email !== "") { writer.uint32(10).string(message.email); } if (message.urls !== undefined) { @@ -172,7 +173,7 @@ export const DashUserSettingsState = { fromJSON(object: any): DashUserSettingsState { return { - email: isSet(object.email) ? String(object.email) : '', + email: isSet(object.email) ? String(object.email) : "", urls: isSet(object.urls) ? DashUserSettingsState_URLs.fromJSON(object.urls) : undefined, flashes: Array.isArray(object?.flashes) ? object.flashes.map((e: any) => DashFlash.fromJSON(e)) : [], }; @@ -184,7 +185,7 @@ export const DashUserSettingsState = { message.urls !== undefined && (obj.urls = message.urls ? DashUserSettingsState_URLs.toJSON(message.urls) : undefined); if (message.flashes) { - obj.flashes = message.flashes.map((e) => (e ? DashFlash.toJSON(e) : undefined)); + obj.flashes = message.flashes.map((e) => e ? DashFlash.toJSON(e) : undefined); } else { obj.flashes = []; } @@ -193,26 +194,25 @@ export const DashUserSettingsState = { fromPartial, I>>(object: I): DashUserSettingsState { const message = createBaseDashUserSettingsState(); - message.email = object.email ?? ''; - message.urls = - object.urls !== undefined && object.urls !== null - ? DashUserSettingsState_URLs.fromPartial(object.urls) - : undefined; + message.email = object.email ?? ""; + message.urls = (object.urls !== undefined && object.urls !== null) + ? DashUserSettingsState_URLs.fromPartial(object.urls) + : undefined; message.flashes = object.flashes?.map((e) => DashFlash.fromPartial(e)) || []; return message; }, }; function createBaseDashUserSettingsState_URLs(): DashUserSettingsState_URLs { - return { connectGoogle: '', connectGithub: '' }; + return { connectGoogle: "", connectGithub: "" }; } export const DashUserSettingsState_URLs = { encode(message: DashUserSettingsState_URLs, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.connectGoogle !== '') { + if (message.connectGoogle !== "") { writer.uint32(10).string(message.connectGoogle); } - if (message.connectGithub !== '') { + if (message.connectGithub !== "") { writer.uint32(18).string(message.connectGithub); } return writer; @@ -241,8 +241,8 @@ export const DashUserSettingsState_URLs = { fromJSON(object: any): DashUserSettingsState_URLs { return { - connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : '', - connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : '', + connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : "", + connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : "", }; }, @@ -255,8 +255,8 @@ export const DashUserSettingsState_URLs = { fromPartial, I>>(object: I): DashUserSettingsState_URLs { const message = createBaseDashUserSettingsState_URLs(); - message.connectGoogle = object.connectGoogle ?? ''; - message.connectGithub = object.connectGithub ?? ''; + message.connectGoogle = object.connectGoogle ?? ""; + message.connectGithub = object.connectGithub ?? ""; return message; }, }; @@ -321,12 +321,10 @@ export class DashStateClientImpl implements DashState { } } -export const DashStateDesc = { - serviceName: 'rpx.DashState', -}; +export const DashStateDesc = { serviceName: "rpx.DashState" }; export const DashStateUserSettingsDesc: UnaryMethodDefinitionish = { - methodName: 'UserSettings', + methodName: "UserSettings", service: DashStateDesc, requestStream: false, responseStream: false, @@ -358,7 +356,7 @@ interface Rpc { unary( methodDesc: T, request: any, - metadata: grpc.Metadata | undefined + metadata: grpc.Metadata | undefined, ): Observable; } @@ -380,7 +378,7 @@ export class GrpcWebImpl { debug?: boolean; metadata?: grpc.Metadata; upStreamRetryCodes?: number[]; - } + }, ) { this.host = host; this.options = options; @@ -389,13 +387,12 @@ export class GrpcWebImpl { unary( methodDesc: T, _request: any, - metadata: grpc.Metadata | undefined + metadata: grpc.Metadata | undefined, ): Observable { const request = { ..._request, ...methodDesc.requestType }; - const maybeCombinedMetadata = - metadata && this.options.metadata - ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) - : metadata || this.options.metadata; + const maybeCombinedMetadata = metadata && this.options.metadata + ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) + : metadata || this.options.metadata; return new Observable((observer) => { grpc.unary(methodDesc, { request, @@ -419,19 +416,13 @@ export class GrpcWebImpl { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/grpc-web-no-streaming/example.ts b/integration/grpc-web-no-streaming/example.ts index 661e2d9cc..bbf9663cd 100644 --- a/integration/grpc-web-no-streaming/example.ts +++ b/integration/grpc-web-no-streaming/example.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { grpc } from '@improbable-eng/grpc-web'; -import { BrowserHeaders } from 'browser-headers'; -import * as _m0 from 'protobufjs/minimal'; +import { grpc } from "@improbable-eng/grpc-web"; +import { BrowserHeaders } from "browser-headers"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'rpx'; +export const protobufPackage = "rpx"; export interface DashFlash { msg: string; @@ -21,19 +21,19 @@ export enum DashFlash_Type { export function dashFlash_TypeFromJSON(object: any): DashFlash_Type { switch (object) { case 0: - case 'Undefined': + case "Undefined": return DashFlash_Type.Undefined; case 1: - case 'Success': + case "Success": return DashFlash_Type.Success; case 2: - case 'Warn': + case "Warn": return DashFlash_Type.Warn; case 3: - case 'Error': + case "Error": return DashFlash_Type.Error; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return DashFlash_Type.UNRECOGNIZED; } @@ -42,16 +42,16 @@ export function dashFlash_TypeFromJSON(object: any): DashFlash_Type { export function dashFlash_TypeToJSON(object: DashFlash_Type): string { switch (object) { case DashFlash_Type.Undefined: - return 'Undefined'; + return "Undefined"; case DashFlash_Type.Success: - return 'Success'; + return "Success"; case DashFlash_Type.Warn: - return 'Warn'; + return "Warn"; case DashFlash_Type.Error: - return 'Error'; + return "Error"; case DashFlash_Type.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -66,15 +66,16 @@ export interface DashUserSettingsState_URLs { connectGithub: string; } -export interface Empty {} +export interface Empty { +} function createBaseDashFlash(): DashFlash { - return { msg: '', type: 0 }; + return { msg: "", type: 0 }; } export const DashFlash = { encode(message: DashFlash, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.msg !== '') { + if (message.msg !== "") { writer.uint32(10).string(message.msg); } if (message.type !== 0) { @@ -106,7 +107,7 @@ export const DashFlash = { fromJSON(object: any): DashFlash { return { - msg: isSet(object.msg) ? String(object.msg) : '', + msg: isSet(object.msg) ? String(object.msg) : "", type: isSet(object.type) ? dashFlash_TypeFromJSON(object.type) : 0, }; }, @@ -120,19 +121,19 @@ export const DashFlash = { fromPartial, I>>(object: I): DashFlash { const message = createBaseDashFlash(); - message.msg = object.msg ?? ''; + message.msg = object.msg ?? ""; message.type = object.type ?? 0; return message; }, }; function createBaseDashUserSettingsState(): DashUserSettingsState { - return { email: '', urls: undefined, flashes: [] }; + return { email: "", urls: undefined, flashes: [] }; } export const DashUserSettingsState = { encode(message: DashUserSettingsState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.email !== '') { + if (message.email !== "") { writer.uint32(10).string(message.email); } if (message.urls !== undefined) { @@ -170,7 +171,7 @@ export const DashUserSettingsState = { fromJSON(object: any): DashUserSettingsState { return { - email: isSet(object.email) ? String(object.email) : '', + email: isSet(object.email) ? String(object.email) : "", urls: isSet(object.urls) ? DashUserSettingsState_URLs.fromJSON(object.urls) : undefined, flashes: Array.isArray(object?.flashes) ? object.flashes.map((e: any) => DashFlash.fromJSON(e)) : [], }; @@ -182,7 +183,7 @@ export const DashUserSettingsState = { message.urls !== undefined && (obj.urls = message.urls ? DashUserSettingsState_URLs.toJSON(message.urls) : undefined); if (message.flashes) { - obj.flashes = message.flashes.map((e) => (e ? DashFlash.toJSON(e) : undefined)); + obj.flashes = message.flashes.map((e) => e ? DashFlash.toJSON(e) : undefined); } else { obj.flashes = []; } @@ -191,26 +192,25 @@ export const DashUserSettingsState = { fromPartial, I>>(object: I): DashUserSettingsState { const message = createBaseDashUserSettingsState(); - message.email = object.email ?? ''; - message.urls = - object.urls !== undefined && object.urls !== null - ? DashUserSettingsState_URLs.fromPartial(object.urls) - : undefined; + message.email = object.email ?? ""; + message.urls = (object.urls !== undefined && object.urls !== null) + ? DashUserSettingsState_URLs.fromPartial(object.urls) + : undefined; message.flashes = object.flashes?.map((e) => DashFlash.fromPartial(e)) || []; return message; }, }; function createBaseDashUserSettingsState_URLs(): DashUserSettingsState_URLs { - return { connectGoogle: '', connectGithub: '' }; + return { connectGoogle: "", connectGithub: "" }; } export const DashUserSettingsState_URLs = { encode(message: DashUserSettingsState_URLs, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.connectGoogle !== '') { + if (message.connectGoogle !== "") { writer.uint32(10).string(message.connectGoogle); } - if (message.connectGithub !== '') { + if (message.connectGithub !== "") { writer.uint32(18).string(message.connectGithub); } return writer; @@ -239,8 +239,8 @@ export const DashUserSettingsState_URLs = { fromJSON(object: any): DashUserSettingsState_URLs { return { - connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : '', - connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : '', + connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : "", + connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : "", }; }, @@ -253,8 +253,8 @@ export const DashUserSettingsState_URLs = { fromPartial, I>>(object: I): DashUserSettingsState_URLs { const message = createBaseDashUserSettingsState_URLs(); - message.connectGoogle = object.connectGoogle ?? ''; - message.connectGithub = object.connectGithub ?? ''; + message.connectGoogle = object.connectGoogle ?? ""; + message.connectGithub = object.connectGithub ?? ""; return message; }, }; @@ -319,12 +319,10 @@ export class DashStateClientImpl implements DashState { } } -export const DashStateDesc = { - serviceName: 'rpx.DashState', -}; +export const DashStateDesc = { serviceName: "rpx.DashState" }; export const DashStateUserSettingsDesc: UnaryMethodDefinitionish = { - methodName: 'UserSettings', + methodName: "UserSettings", service: DashStateDesc, requestStream: false, responseStream: false, @@ -356,7 +354,7 @@ interface Rpc { unary( methodDesc: T, request: any, - metadata: grpc.Metadata | undefined + metadata: grpc.Metadata | undefined, ): Promise; } @@ -378,7 +376,7 @@ export class GrpcWebImpl { debug?: boolean; metadata?: grpc.Metadata; upStreamRetryCodes?: number[]; - } + }, ) { this.host = host; this.options = options; @@ -387,13 +385,12 @@ export class GrpcWebImpl { unary( methodDesc: T, _request: any, - metadata: grpc.Metadata | undefined + metadata: grpc.Metadata | undefined, ): Promise { const request = { ..._request, ...methodDesc.requestType }; - const maybeCombinedMetadata = - metadata && this.options.metadata - ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) - : metadata || this.options.metadata; + const maybeCombinedMetadata = metadata && this.options.metadata + ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) + : metadata || this.options.metadata; return new Promise((resolve, reject) => { grpc.unary(methodDesc, { request, @@ -416,19 +413,13 @@ export class GrpcWebImpl { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/grpc-web/example.ts b/integration/grpc-web/example.ts index 415ad994e..e4d52fae9 100644 --- a/integration/grpc-web/example.ts +++ b/integration/grpc-web/example.ts @@ -1,11 +1,11 @@ /* eslint-disable */ -import { grpc } from '@improbable-eng/grpc-web'; -import { BrowserHeaders } from 'browser-headers'; -import { share } from 'rxjs/operators'; -import { Observable } from 'rxjs'; -import * as _m0 from 'protobufjs/minimal'; +import { grpc } from "@improbable-eng/grpc-web"; +import { BrowserHeaders } from "browser-headers"; +import { share } from "rxjs/operators"; +import { Observable } from "rxjs"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'rpx'; +export const protobufPackage = "rpx"; export interface DashFlash { msg: string; @@ -23,19 +23,19 @@ export enum DashFlash_Type { export function dashFlash_TypeFromJSON(object: any): DashFlash_Type { switch (object) { case 0: - case 'Undefined': + case "Undefined": return DashFlash_Type.Undefined; case 1: - case 'Success': + case "Success": return DashFlash_Type.Success; case 2: - case 'Warn': + case "Warn": return DashFlash_Type.Warn; case 3: - case 'Error': + case "Error": return DashFlash_Type.Error; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return DashFlash_Type.UNRECOGNIZED; } @@ -44,16 +44,16 @@ export function dashFlash_TypeFromJSON(object: any): DashFlash_Type { export function dashFlash_TypeToJSON(object: DashFlash_Type): string { switch (object) { case DashFlash_Type.Undefined: - return 'Undefined'; + return "Undefined"; case DashFlash_Type.Success: - return 'Success'; + return "Success"; case DashFlash_Type.Warn: - return 'Warn'; + return "Warn"; case DashFlash_Type.Error: - return 'Error'; + return "Error"; case DashFlash_Type.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -92,15 +92,16 @@ export interface DashAPICredsDeleteReq { id: string; } -export interface Empty {} +export interface Empty { +} function createBaseDashFlash(): DashFlash { - return { msg: '', type: 0 }; + return { msg: "", type: 0 }; } export const DashFlash = { encode(message: DashFlash, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.msg !== '') { + if (message.msg !== "") { writer.uint32(10).string(message.msg); } if (message.type !== 0) { @@ -132,7 +133,7 @@ export const DashFlash = { fromJSON(object: any): DashFlash { return { - msg: isSet(object.msg) ? String(object.msg) : '', + msg: isSet(object.msg) ? String(object.msg) : "", type: isSet(object.type) ? dashFlash_TypeFromJSON(object.type) : 0, }; }, @@ -146,19 +147,19 @@ export const DashFlash = { fromPartial, I>>(object: I): DashFlash { const message = createBaseDashFlash(); - message.msg = object.msg ?? ''; + message.msg = object.msg ?? ""; message.type = object.type ?? 0; return message; }, }; function createBaseDashUserSettingsState(): DashUserSettingsState { - return { email: '', urls: undefined, flashes: [] }; + return { email: "", urls: undefined, flashes: [] }; } export const DashUserSettingsState = { encode(message: DashUserSettingsState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.email !== '') { + if (message.email !== "") { writer.uint32(10).string(message.email); } if (message.urls !== undefined) { @@ -196,7 +197,7 @@ export const DashUserSettingsState = { fromJSON(object: any): DashUserSettingsState { return { - email: isSet(object.email) ? String(object.email) : '', + email: isSet(object.email) ? String(object.email) : "", urls: isSet(object.urls) ? DashUserSettingsState_URLs.fromJSON(object.urls) : undefined, flashes: Array.isArray(object?.flashes) ? object.flashes.map((e: any) => DashFlash.fromJSON(e)) : [], }; @@ -208,7 +209,7 @@ export const DashUserSettingsState = { message.urls !== undefined && (obj.urls = message.urls ? DashUserSettingsState_URLs.toJSON(message.urls) : undefined); if (message.flashes) { - obj.flashes = message.flashes.map((e) => (e ? DashFlash.toJSON(e) : undefined)); + obj.flashes = message.flashes.map((e) => e ? DashFlash.toJSON(e) : undefined); } else { obj.flashes = []; } @@ -217,26 +218,25 @@ export const DashUserSettingsState = { fromPartial, I>>(object: I): DashUserSettingsState { const message = createBaseDashUserSettingsState(); - message.email = object.email ?? ''; - message.urls = - object.urls !== undefined && object.urls !== null - ? DashUserSettingsState_URLs.fromPartial(object.urls) - : undefined; + message.email = object.email ?? ""; + message.urls = (object.urls !== undefined && object.urls !== null) + ? DashUserSettingsState_URLs.fromPartial(object.urls) + : undefined; message.flashes = object.flashes?.map((e) => DashFlash.fromPartial(e)) || []; return message; }, }; function createBaseDashUserSettingsState_URLs(): DashUserSettingsState_URLs { - return { connectGoogle: '', connectGithub: '' }; + return { connectGoogle: "", connectGithub: "" }; } export const DashUserSettingsState_URLs = { encode(message: DashUserSettingsState_URLs, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.connectGoogle !== '') { + if (message.connectGoogle !== "") { writer.uint32(10).string(message.connectGoogle); } - if (message.connectGithub !== '') { + if (message.connectGithub !== "") { writer.uint32(18).string(message.connectGithub); } return writer; @@ -265,8 +265,8 @@ export const DashUserSettingsState_URLs = { fromJSON(object: any): DashUserSettingsState_URLs { return { - connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : '', - connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : '', + connectGoogle: isSet(object.connectGoogle) ? String(object.connectGoogle) : "", + connectGithub: isSet(object.connectGithub) ? String(object.connectGithub) : "", }; }, @@ -279,28 +279,28 @@ export const DashUserSettingsState_URLs = { fromPartial, I>>(object: I): DashUserSettingsState_URLs { const message = createBaseDashUserSettingsState_URLs(); - message.connectGoogle = object.connectGoogle ?? ''; - message.connectGithub = object.connectGithub ?? ''; + message.connectGoogle = object.connectGoogle ?? ""; + message.connectGithub = object.connectGithub ?? ""; return message; }, }; function createBaseDashCred(): DashCred { - return { description: '', metadata: '', token: '', id: '' }; + return { description: "", metadata: "", token: "", id: "" }; } export const DashCred = { encode(message: DashCred, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.description !== '') { + if (message.description !== "") { writer.uint32(18).string(message.description); } - if (message.metadata !== '') { + if (message.metadata !== "") { writer.uint32(26).string(message.metadata); } - if (message.token !== '') { + if (message.token !== "") { writer.uint32(34).string(message.token); } - if (message.id !== '') { + if (message.id !== "") { writer.uint32(58).string(message.id); } return writer; @@ -335,10 +335,10 @@ export const DashCred = { fromJSON(object: any): DashCred { return { - description: isSet(object.description) ? String(object.description) : '', - metadata: isSet(object.metadata) ? String(object.metadata) : '', - token: isSet(object.token) ? String(object.token) : '', - id: isSet(object.id) ? String(object.id) : '', + description: isSet(object.description) ? String(object.description) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "", + token: isSet(object.token) ? String(object.token) : "", + id: isSet(object.id) ? String(object.id) : "", }; }, @@ -353,24 +353,24 @@ export const DashCred = { fromPartial, I>>(object: I): DashCred { const message = createBaseDashCred(); - message.description = object.description ?? ''; - message.metadata = object.metadata ?? ''; - message.token = object.token ?? ''; - message.id = object.id ?? ''; + message.description = object.description ?? ""; + message.metadata = object.metadata ?? ""; + message.token = object.token ?? ""; + message.id = object.id ?? ""; return message; }, }; function createBaseDashAPICredsCreateReq(): DashAPICredsCreateReq { - return { description: '', metadata: '' }; + return { description: "", metadata: "" }; } export const DashAPICredsCreateReq = { encode(message: DashAPICredsCreateReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.description !== '') { + if (message.description !== "") { writer.uint32(10).string(message.description); } - if (message.metadata !== '') { + if (message.metadata !== "") { writer.uint32(18).string(message.metadata); } return writer; @@ -399,8 +399,8 @@ export const DashAPICredsCreateReq = { fromJSON(object: any): DashAPICredsCreateReq { return { - description: isSet(object.description) ? String(object.description) : '', - metadata: isSet(object.metadata) ? String(object.metadata) : '', + description: isSet(object.description) ? String(object.description) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "", }; }, @@ -413,28 +413,28 @@ export const DashAPICredsCreateReq = { fromPartial, I>>(object: I): DashAPICredsCreateReq { const message = createBaseDashAPICredsCreateReq(); - message.description = object.description ?? ''; - message.metadata = object.metadata ?? ''; + message.description = object.description ?? ""; + message.metadata = object.metadata ?? ""; return message; }, }; function createBaseDashAPICredsUpdateReq(): DashAPICredsUpdateReq { - return { credSid: '', description: '', metadata: '', id: '' }; + return { credSid: "", description: "", metadata: "", id: "" }; } export const DashAPICredsUpdateReq = { encode(message: DashAPICredsUpdateReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.credSid !== '') { + if (message.credSid !== "") { writer.uint32(10).string(message.credSid); } - if (message.description !== '') { + if (message.description !== "") { writer.uint32(18).string(message.description); } - if (message.metadata !== '') { + if (message.metadata !== "") { writer.uint32(26).string(message.metadata); } - if (message.id !== '') { + if (message.id !== "") { writer.uint32(42).string(message.id); } return writer; @@ -469,10 +469,10 @@ export const DashAPICredsUpdateReq = { fromJSON(object: any): DashAPICredsUpdateReq { return { - credSid: isSet(object.credSid) ? String(object.credSid) : '', - description: isSet(object.description) ? String(object.description) : '', - metadata: isSet(object.metadata) ? String(object.metadata) : '', - id: isSet(object.id) ? String(object.id) : '', + credSid: isSet(object.credSid) ? String(object.credSid) : "", + description: isSet(object.description) ? String(object.description) : "", + metadata: isSet(object.metadata) ? String(object.metadata) : "", + id: isSet(object.id) ? String(object.id) : "", }; }, @@ -487,24 +487,24 @@ export const DashAPICredsUpdateReq = { fromPartial, I>>(object: I): DashAPICredsUpdateReq { const message = createBaseDashAPICredsUpdateReq(); - message.credSid = object.credSid ?? ''; - message.description = object.description ?? ''; - message.metadata = object.metadata ?? ''; - message.id = object.id ?? ''; + message.credSid = object.credSid ?? ""; + message.description = object.description ?? ""; + message.metadata = object.metadata ?? ""; + message.id = object.id ?? ""; return message; }, }; function createBaseDashAPICredsDeleteReq(): DashAPICredsDeleteReq { - return { credSid: '', id: '' }; + return { credSid: "", id: "" }; } export const DashAPICredsDeleteReq = { encode(message: DashAPICredsDeleteReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.credSid !== '') { + if (message.credSid !== "") { writer.uint32(10).string(message.credSid); } - if (message.id !== '') { + if (message.id !== "") { writer.uint32(26).string(message.id); } return writer; @@ -533,8 +533,8 @@ export const DashAPICredsDeleteReq = { fromJSON(object: any): DashAPICredsDeleteReq { return { - credSid: isSet(object.credSid) ? String(object.credSid) : '', - id: isSet(object.id) ? String(object.id) : '', + credSid: isSet(object.credSid) ? String(object.credSid) : "", + id: isSet(object.id) ? String(object.id) : "", }; }, @@ -547,8 +547,8 @@ export const DashAPICredsDeleteReq = { fromPartial, I>>(object: I): DashAPICredsDeleteReq { const message = createBaseDashAPICredsDeleteReq(); - message.credSid = object.credSid ?? ''; - message.id = object.id ?? ''; + message.credSid = object.credSid ?? ""; + message.id = object.id ?? ""; return message; }, }; @@ -598,7 +598,7 @@ export interface DashState { /** not supported in grpc-web, but should still compile */ ChangeUserSettingsStream( request: Observable>, - metadata?: grpc.Metadata + metadata?: grpc.Metadata, ): Observable; } @@ -622,18 +622,16 @@ export class DashStateClientImpl implements DashState { ChangeUserSettingsStream( request: Observable>, - metadata?: grpc.Metadata + metadata?: grpc.Metadata, ): Observable { - throw new Error('ts-proto does not yet support client streaming!'); + throw new Error("ts-proto does not yet support client streaming!"); } } -export const DashStateDesc = { - serviceName: 'rpx.DashState', -}; +export const DashStateDesc = { serviceName: "rpx.DashState" }; export const DashStateUserSettingsDesc: UnaryMethodDefinitionish = { - methodName: 'UserSettings', + methodName: "UserSettings", service: DashStateDesc, requestStream: false, responseStream: false, @@ -655,7 +653,7 @@ export const DashStateUserSettingsDesc: UnaryMethodDefinitionish = { }; export const DashStateActiveUserSettingsStreamDesc: UnaryMethodDefinitionish = { - methodName: 'ActiveUserSettingsStream', + methodName: "ActiveUserSettingsStream", service: DashStateDesc, requestStream: false, responseStream: true, @@ -710,12 +708,10 @@ export class DashAPICredsClientImpl implements DashAPICreds { } } -export const DashAPICredsDesc = { - serviceName: 'rpx.DashAPICreds', -}; +export const DashAPICredsDesc = { serviceName: "rpx.DashAPICreds" }; export const DashAPICredsCreateDesc: UnaryMethodDefinitionish = { - methodName: 'Create', + methodName: "Create", service: DashAPICredsDesc, requestStream: false, responseStream: false, @@ -737,7 +733,7 @@ export const DashAPICredsCreateDesc: UnaryMethodDefinitionish = { }; export const DashAPICredsUpdateDesc: UnaryMethodDefinitionish = { - methodName: 'Update', + methodName: "Update", service: DashAPICredsDesc, requestStream: false, responseStream: false, @@ -759,7 +755,7 @@ export const DashAPICredsUpdateDesc: UnaryMethodDefinitionish = { }; export const DashAPICredsDeleteDesc: UnaryMethodDefinitionish = { - methodName: 'Delete', + methodName: "Delete", service: DashAPICredsDesc, requestStream: false, responseStream: false, @@ -791,12 +787,12 @@ interface Rpc { unary( methodDesc: T, request: any, - metadata: grpc.Metadata | undefined + metadata: grpc.Metadata | undefined, ): Promise; invoke( methodDesc: T, request: any, - metadata: grpc.Metadata | undefined + metadata: grpc.Metadata | undefined, ): Observable; } @@ -818,7 +814,7 @@ export class GrpcWebImpl { debug?: boolean; metadata?: grpc.Metadata; upStreamRetryCodes?: number[]; - } + }, ) { this.host = host; this.options = options; @@ -827,13 +823,12 @@ export class GrpcWebImpl { unary( methodDesc: T, _request: any, - metadata: grpc.Metadata | undefined + metadata: grpc.Metadata | undefined, ): Promise { const request = { ..._request, ...methodDesc.requestType }; - const maybeCombinedMetadata = - metadata && this.options.metadata - ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) - : metadata || this.options.metadata; + const maybeCombinedMetadata = metadata && this.options.metadata + ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) + : metadata || this.options.metadata; return new Promise((resolve, reject) => { grpc.unary(methodDesc, { request, @@ -856,17 +851,16 @@ export class GrpcWebImpl { invoke( methodDesc: T, _request: any, - metadata: grpc.Metadata | undefined + metadata: grpc.Metadata | undefined, ): Observable { const upStreamCodes = this.options.upStreamRetryCodes || []; const DEFAULT_TIMEOUT_TIME: number = 3_000; const request = { ..._request, ...methodDesc.requestType }; - const maybeCombinedMetadata = - metadata && this.options.metadata - ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) - : metadata || this.options.metadata; + const maybeCombinedMetadata = metadata && this.options.metadata + ? new BrowserHeaders({ ...this.options?.metadata.headersMap, ...metadata?.headersMap }) + : metadata || this.options.metadata; return new Observable((observer) => { - const upStream = () => { + const upStream = (() => { const client = grpc.invoke(methodDesc, { host: this.host, request, @@ -888,7 +882,7 @@ export class GrpcWebImpl { }, }); observer.add(() => client.close()); - }; + }); upStream(); }).pipe(share()); } @@ -896,19 +890,13 @@ export class GrpcWebImpl { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/import-suffix/child.pb.ts b/integration/import-suffix/child.pb.ts index 12d9d2f83..b0da17050 100644 --- a/integration/import-suffix/child.pb.ts +++ b/integration/import-suffix/child.pb.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal.js'; +import * as _m0 from "protobufjs/minimal.js"; -export const protobufPackage = 'file_suffix'; +export const protobufPackage = "file_suffix"; export enum ChildEnum { DEFAULT = 0, @@ -12,13 +12,13 @@ export enum ChildEnum { export function childEnumFromJSON(object: any): ChildEnum { switch (object) { case 0: - case 'DEFAULT': + case "DEFAULT": return ChildEnum.DEFAULT; case 1: - case 'FOO': + case "FOO": return ChildEnum.FOO; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return ChildEnum.UNRECOGNIZED; } @@ -27,12 +27,12 @@ export function childEnumFromJSON(object: any): ChildEnum { export function childEnumToJSON(object: ChildEnum): string { switch (object) { case ChildEnum.DEFAULT: - return 'DEFAULT'; + return "DEFAULT"; case ChildEnum.FOO: - return 'FOO'; + return "FOO"; case ChildEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -41,12 +41,12 @@ export interface Child { } function createBaseChild(): Child { - return { name: '' }; + return { name: "" }; } export const Child = { encode(message: Child, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -71,9 +71,7 @@ export const Child = { }, fromJSON(object: any): Child { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Child): unknown { @@ -84,26 +82,20 @@ export const Child = { fromPartial, I>>(object: I): Child { const message = createBaseChild(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/import-suffix/google/protobuf/timestamp.pb.ts b/integration/import-suffix/google/protobuf/timestamp.pb.ts index fd7704332..5d5da9d85 100644 --- a/integration/import-suffix/google/protobuf/timestamp.pb.ts +++ b/integration/import-suffix/google/protobuf/timestamp.pb.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal.js'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal.js"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/import-suffix/parent.pb.ts b/integration/import-suffix/parent.pb.ts index 58ef39126..118805d95 100644 --- a/integration/import-suffix/parent.pb.ts +++ b/integration/import-suffix/parent.pb.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { ChildEnum, Child, childEnumFromJSON, childEnumToJSON } from './child.pb.js'; -import { Timestamp } from './google/protobuf/timestamp.pb.js'; -import * as _m0 from 'protobufjs/minimal.js'; +import { Child, ChildEnum, childEnumFromJSON, childEnumToJSON } from "./child.pb.js"; +import { Timestamp } from "./google/protobuf/timestamp.pb.js"; +import * as _m0 from "protobufjs/minimal.js"; -export const protobufPackage = 'file_suffix'; +export const protobufPackage = "file_suffix"; export interface Parent { child: Child | undefined; @@ -71,7 +71,7 @@ export const Parent = { fromPartial, I>>(object: I): Parent { const message = createBaseParent(); - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; message.childEnum = object.childEnum ?? 0; message.createdAt = object.createdAt ?? undefined; return message; @@ -80,19 +80,13 @@ export const Parent = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -110,7 +104,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/lower-case-svc-methods/math.ts b/integration/lower-case-svc-methods/math.ts index 4a2cd8780..a54bcd803 100644 --- a/integration/lower-case-svc-methods/math.ts +++ b/integration/lower-case-svc-methods/math.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import * as DataLoader from 'dataloader'; -import * as hash from 'object-hash'; -import * as _m0 from 'protobufjs/minimal'; +import * as DataLoader from "dataloader"; +import * as hash from "object-hash"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface NumPair { num1: number; @@ -55,10 +55,7 @@ export const NumPair = { }, fromJSON(object: any): NumPair { - return { - num1: isSet(object.num1) ? Number(object.num1) : 0, - num2: isSet(object.num2) ? Number(object.num2) : 0, - }; + return { num1: isSet(object.num1) ? Number(object.num1) : 0, num2: isSet(object.num2) ? Number(object.num2) : 0 }; }, toJSON(message: NumPair): unknown { @@ -107,9 +104,7 @@ export const NumSingle = { }, fromJSON(object: any): NumSingle { - return { - num: isSet(object.num) ? Number(object.num) : 0, - }; + return { num: isSet(object.num) ? Number(object.num) : 0 }; }, toJSON(message: NumSingle): unknown { @@ -165,9 +160,7 @@ export const Numbers = { }, fromJSON(object: any): Numbers { - return { - num: Array.isArray(object?.num) ? object.num.map((e: any) => Number(e)) : [], - }; + return { num: Array.isArray(object?.num) ? object.num.map((e: any) => Number(e)) : [] }; }, toJSON(message: Numbers): unknown { @@ -204,32 +197,29 @@ export class MathServiceClientImpl implements MathS } add(ctx: Context, request: NumPair): Promise { const data = NumPair.encode(request).finish(); - const promise = this.rpc.request(ctx, 'MathService', 'Add', data); + const promise = this.rpc.request(ctx, "MathService", "Add", data); return promise.then((data) => NumSingle.decode(new _m0.Reader(data))); } absoluteValue(ctx: Context, request: NumSingle): Promise { const data = NumSingle.encode(request).finish(); - const promise = this.rpc.request(ctx, 'MathService', 'AbsoluteValue', data); + const promise = this.rpc.request(ctx, "MathService", "AbsoluteValue", data); return promise.then((data) => NumSingle.decode(new _m0.Reader(data))); } getDouble(ctx: Context, nu: number): Promise { - const dl = ctx.getDataLoader('MathService.BatchDouble', () => { - return new DataLoader( - (num) => { - const request = { num }; - return this.batchDouble(ctx, request).then((res) => res.num); - }, - { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions } - ); + const dl = ctx.getDataLoader("MathService.BatchDouble", () => { + return new DataLoader((num) => { + const request = { num }; + return this.batchDouble(ctx, request).then((res) => res.num); + }, { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions }); }); return dl.load(nu); } batchDouble(ctx: Context, request: Numbers): Promise { const data = Numbers.encode(request).finish(); - const promise = this.rpc.request(ctx, 'MathService', 'BatchDouble', data); + const promise = this.rpc.request(ctx, "MathService", "BatchDouble", data); return promise.then((data) => Numbers.decode(new _m0.Reader(data))); } } @@ -249,19 +239,13 @@ export interface DataLoaders { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/meta-typings/google/protobuf/timestamp.ts b/integration/meta-typings/google/protobuf/timestamp.ts index e1da649fe..3af6bfea4 100644 --- a/integration/meta-typings/google/protobuf/timestamp.ts +++ b/integration/meta-typings/google/protobuf/timestamp.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { FileDescriptorProto } from 'ts-proto-descriptors'; -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import { FileDescriptorProto } from "ts-proto-descriptors"; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -56,7 +56,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -65,7 +64,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -165,128 +163,109 @@ export interface ProtoMetadata { options?: { options?: { [key: string]: any }; services?: { - [key: string]: { - options?: { [key: string]: any }; - methods?: { [key: string]: { [key: string]: any } }; - }; - }; - messages?: { - [key: string]: ProtoMetaMessageOptions; - }; - enums?: { - [key: string]: { - options?: { [key: string]: any }; - values?: { [key: string]: { [key: string]: any } }; - }; + [key: string]: { options?: { [key: string]: any }; methods?: { [key: string]: { [key: string]: any } } }; }; + messages?: { [key: string]: ProtoMetaMessageOptions }; + enums?: { [key: string]: { options?: { [key: string]: any }; values?: { [key: string]: { [key: string]: any } } } }; }; } export const protoMetadata: ProtoMetadata = { fileDescriptor: FileDescriptorProto.fromPartial({ - name: 'google/protobuf/timestamp.proto', - package: 'google.protobuf', - dependency: [], - publicDependency: [], - weakDependency: [], - messageType: [ - { - name: 'Timestamp', - field: [ - { - name: 'seconds', - number: 1, - label: 1, - type: 3, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'seconds', - options: undefined, - proto3Optional: false, - }, - { - name: 'nanos', - number: 2, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'nanos', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - service: [], - extension: [], - options: { - javaPackage: 'com.google.protobuf', - javaOuterClassname: 'TimestampProto', - javaMultipleFiles: true, - javaGenerateEqualsAndHash: false, - javaStringCheckUtf8: false, - optimizeFor: 1, - goPackage: 'google.golang.org/protobuf/types/known/timestamppb', - ccGenericServices: false, - javaGenericServices: false, - pyGenericServices: false, - phpGenericServices: false, - deprecated: false, - ccEnableArenas: true, - objcClassPrefix: 'GPB', - csharpNamespace: 'Google.Protobuf.WellKnownTypes', - swiftPrefix: '', - phpClassPrefix: '', - phpNamespace: '', - phpMetadataNamespace: '', - rubyPackage: '', - uninterpretedOption: [], + "name": "google/protobuf/timestamp.proto", + "package": "google.protobuf", + "dependency": [], + "publicDependency": [], + "weakDependency": [], + "messageType": [{ + "name": "Timestamp", + "field": [{ + "name": "seconds", + "number": 1, + "label": 1, + "type": 3, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "seconds", + "options": undefined, + "proto3Optional": false, + }, { + "name": "nanos", + "number": 2, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "nanos", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "service": [], + "extension": [], + "options": { + "javaPackage": "com.google.protobuf", + "javaOuterClassname": "TimestampProto", + "javaMultipleFiles": true, + "javaGenerateEqualsAndHash": false, + "javaStringCheckUtf8": false, + "optimizeFor": 1, + "goPackage": "google.golang.org/protobuf/types/known/timestamppb", + "ccGenericServices": false, + "javaGenericServices": false, + "pyGenericServices": false, + "phpGenericServices": false, + "deprecated": false, + "ccEnableArenas": true, + "objcClassPrefix": "GPB", + "csharpNamespace": "Google.Protobuf.WellKnownTypes", + "swiftPrefix": "", + "phpClassPrefix": "", + "phpNamespace": "", + "phpMetadataNamespace": "", + "rubyPackage": "", + "uninterpretedOption": [], }, - sourceCodeInfo: { - location: [ - { - path: [4, 0], - span: [135, 0, 146, 1], - leadingComments: - ' A Timestamp represents a point in time independent of any time zone or local\n calendar, encoded as a count of seconds and fractions of seconds at\n nanosecond resolution. The count is relative to an epoch at UTC midnight on\n January 1, 1970, in the proleptic Gregorian calendar which extends the\n Gregorian calendar backwards to year one.\n\n All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap\n second table is needed for interpretation, using a [24-hour linear\n smear](https://developers.google.com/time/smear).\n\n The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n restricting to that range, we ensure that we can convert to and from [RFC\n 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n\n # Examples\n\n Example 1: Compute Timestamp from POSIX `time()`.\n\n Timestamp timestamp;\n timestamp.set_seconds(time(NULL));\n timestamp.set_nanos(0);\n\n Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n\n struct timeval tv;\n gettimeofday(&tv, NULL);\n\n Timestamp timestamp;\n timestamp.set_seconds(tv.tv_sec);\n timestamp.set_nanos(tv.tv_usec * 1000);\n\n Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n\n FILETIME ft;\n GetSystemTimeAsFileTime(&ft);\n UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n\n // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n Timestamp timestamp;\n timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n\n Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n\n long millis = System.currentTimeMillis();\n\n Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n .setNanos((int) ((millis % 1000) * 1000000)).build();\n\n\n Example 5: Compute Timestamp from Java `Instant.now()`.\n\n Instant now = Instant.now();\n\n Timestamp timestamp =\n Timestamp.newBuilder().setSeconds(now.getEpochSecond())\n .setNanos(now.getNano()).build();\n\n\n Example 6: Compute Timestamp from current time in Python.\n\n timestamp = Timestamp()\n timestamp.GetCurrentTime()\n\n # JSON Mapping\n\n In JSON format, the Timestamp type is encoded as a string in the\n [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"\n where {year} is always expressed using four digits while {month}, {day},\n {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone\n is required. A proto3 JSON serializer should always use UTC (as indicated by\n "Z") when printing the Timestamp type and a proto3 JSON parser should be\n able to accept both UTC and other timezones (as indicated by an offset).\n\n For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past\n 01:30 UTC on January 15, 2017.\n\n In JavaScript, one can convert a Date object to this format using the\n standard\n [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n method. In Python, a standard `datetime.datetime` object can be converted\n to this format using\n [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n the time format spec \'%Y-%m-%dT%H:%M:%S.%fZ\'. Likewise, in Java, one can use\n the Joda Time\'s [`ISODateTimeFormat.dateTime()`](\n http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D\n ) to obtain a formatter capable of generating timestamps in this format.\n\n\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 0, 2, 0], - span: [139, 2, 20], - leadingComments: - ' Represents seconds of UTC time since Unix epoch\n 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n 9999-12-31T23:59:59Z inclusive.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 0, 2, 1], - span: [145, 2, 18], - leadingComments: - ' Non-negative fractions of a second at nanosecond resolution. Negative\n second values with fractions must still have non-negative nanos values\n that count forward in time. Must be from 0 to 999,999,999\n inclusive.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - ], + "sourceCodeInfo": { + "location": [{ + "path": [4, 0], + "span": [135, 0, 146, 1], + "leadingComments": + ' A Timestamp represents a point in time independent of any time zone or local\n calendar, encoded as a count of seconds and fractions of seconds at\n nanosecond resolution. The count is relative to an epoch at UTC midnight on\n January 1, 1970, in the proleptic Gregorian calendar which extends the\n Gregorian calendar backwards to year one.\n\n All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap\n second table is needed for interpretation, using a [24-hour linear\n smear](https://developers.google.com/time/smear).\n\n The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n restricting to that range, we ensure that we can convert to and from [RFC\n 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n\n # Examples\n\n Example 1: Compute Timestamp from POSIX `time()`.\n\n Timestamp timestamp;\n timestamp.set_seconds(time(NULL));\n timestamp.set_nanos(0);\n\n Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n\n struct timeval tv;\n gettimeofday(&tv, NULL);\n\n Timestamp timestamp;\n timestamp.set_seconds(tv.tv_sec);\n timestamp.set_nanos(tv.tv_usec * 1000);\n\n Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n\n FILETIME ft;\n GetSystemTimeAsFileTime(&ft);\n UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n\n // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n Timestamp timestamp;\n timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n\n Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n\n long millis = System.currentTimeMillis();\n\n Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n .setNanos((int) ((millis % 1000) * 1000000)).build();\n\n\n Example 5: Compute Timestamp from Java `Instant.now()`.\n\n Instant now = Instant.now();\n\n Timestamp timestamp =\n Timestamp.newBuilder().setSeconds(now.getEpochSecond())\n .setNanos(now.getNano()).build();\n\n\n Example 6: Compute Timestamp from current time in Python.\n\n timestamp = Timestamp()\n timestamp.GetCurrentTime()\n\n # JSON Mapping\n\n In JSON format, the Timestamp type is encoded as a string in the\n [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"\n where {year} is always expressed using four digits while {month}, {day},\n {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone\n is required. A proto3 JSON serializer should always use UTC (as indicated by\n "Z") when printing the Timestamp type and a proto3 JSON parser should be\n able to accept both UTC and other timezones (as indicated by an offset).\n\n For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past\n 01:30 UTC on January 15, 2017.\n\n In JavaScript, one can convert a Date object to this format using the\n standard\n [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n method. In Python, a standard `datetime.datetime` object can be converted\n to this format using\n [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n the time format spec \'%Y-%m-%dT%H:%M:%S.%fZ\'. Likewise, in Java, one can use\n the Joda Time\'s [`ISODateTimeFormat.dateTime()`](\n http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D\n ) to obtain a formatter capable of generating timestamps in this format.\n\n\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 0, 2, 0], + "span": [139, 2, 20], + "leadingComments": + " Represents seconds of UTC time since Unix epoch\n 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n 9999-12-31T23:59:59Z inclusive.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 0, 2, 1], + "span": [145, 2, 18], + "leadingComments": + " Non-negative fractions of a second at nanosecond resolution. Negative\n second values with fractions must still have non-negative nanos values\n that count forward in time. Must be from 0 to 999,999,999\n inclusive.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }], }, - syntax: 'proto3', + "syntax": "proto3", }), - references: { '.google.protobuf.Timestamp': Timestamp }, + references: { ".google.protobuf.Timestamp": Timestamp }, dependencies: [], }; @@ -294,16 +273,24 @@ 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'; + 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 longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/meta-typings/google/protobuf/wrappers.ts b/integration/meta-typings/google/protobuf/wrappers.ts index f567d95d2..13a5e17ac 100644 --- a/integration/meta-typings/google/protobuf/wrappers.ts +++ b/integration/meta-typings/google/protobuf/wrappers.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { FileDescriptorProto } from 'ts-proto-descriptors'; -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import { FileDescriptorProto } from "ts-proto-descriptors"; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -313,12 +313,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -388,443 +388,386 @@ export interface ProtoMetadata { options?: { options?: { [key: string]: any }; services?: { - [key: string]: { - options?: { [key: string]: any }; - methods?: { [key: string]: { [key: string]: any } }; - }; - }; - messages?: { - [key: string]: ProtoMetaMessageOptions; - }; - enums?: { - [key: string]: { - options?: { [key: string]: any }; - values?: { [key: string]: { [key: string]: any } }; - }; + [key: string]: { options?: { [key: string]: any }; methods?: { [key: string]: { [key: string]: any } } }; }; + messages?: { [key: string]: ProtoMetaMessageOptions }; + enums?: { [key: string]: { options?: { [key: string]: any }; values?: { [key: string]: { [key: string]: any } } } }; }; } export const protoMetadata: ProtoMetadata = { fileDescriptor: FileDescriptorProto.fromPartial({ - name: 'google/protobuf/wrappers.proto', - package: 'google.protobuf', - dependency: [], - publicDependency: [], - weakDependency: [], - messageType: [ - { - name: 'DoubleValue', - field: [ - { - name: 'value', - number: 1, - label: 1, - type: 1, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'FloatValue', - field: [ - { - name: 'value', - number: 1, - label: 1, - type: 2, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'Int64Value', - field: [ - { - name: 'value', - number: 1, - label: 1, - type: 3, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'UInt64Value', - field: [ - { - name: 'value', - number: 1, - label: 1, - type: 4, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'Int32Value', - field: [ - { - name: 'value', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'UInt32Value', - field: [ - { - name: 'value', - number: 1, - label: 1, - type: 13, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'BoolValue', - field: [ - { - name: 'value', - number: 1, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'StringValue', - field: [ - { - name: 'value', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'BytesValue', - field: [ - { - name: 'value', - number: 1, - label: 1, - type: 12, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - service: [], - extension: [], - options: { - javaPackage: 'com.google.protobuf', - javaOuterClassname: 'WrappersProto', - javaMultipleFiles: true, - javaGenerateEqualsAndHash: false, - javaStringCheckUtf8: false, - optimizeFor: 1, - goPackage: 'github.com/golang/protobuf/ptypes/wrappers', - ccGenericServices: false, - javaGenericServices: false, - pyGenericServices: false, - phpGenericServices: false, - deprecated: false, - ccEnableArenas: true, - objcClassPrefix: 'GPB', - csharpNamespace: 'Google.Protobuf.WellKnownTypes', - swiftPrefix: '', - phpClassPrefix: '', - phpNamespace: '', - phpMetadataNamespace: '', - rubyPackage: '', - uninterpretedOption: [], + "name": "google/protobuf/wrappers.proto", + "package": "google.protobuf", + "dependency": [], + "publicDependency": [], + "weakDependency": [], + "messageType": [{ + "name": "DoubleValue", + "field": [{ + "name": "value", + "number": 1, + "label": 1, + "type": 1, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "FloatValue", + "field": [{ + "name": "value", + "number": 1, + "label": 1, + "type": 2, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "Int64Value", + "field": [{ + "name": "value", + "number": 1, + "label": 1, + "type": 3, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "UInt64Value", + "field": [{ + "name": "value", + "number": 1, + "label": 1, + "type": 4, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "Int32Value", + "field": [{ + "name": "value", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "UInt32Value", + "field": [{ + "name": "value", + "number": 1, + "label": 1, + "type": 13, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "BoolValue", + "field": [{ + "name": "value", + "number": 1, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "StringValue", + "field": [{ + "name": "value", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "BytesValue", + "field": [{ + "name": "value", + "number": 1, + "label": 1, + "type": 12, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "service": [], + "extension": [], + "options": { + "javaPackage": "com.google.protobuf", + "javaOuterClassname": "WrappersProto", + "javaMultipleFiles": true, + "javaGenerateEqualsAndHash": false, + "javaStringCheckUtf8": false, + "optimizeFor": 1, + "goPackage": "github.com/golang/protobuf/ptypes/wrappers", + "ccGenericServices": false, + "javaGenericServices": false, + "pyGenericServices": false, + "phpGenericServices": false, + "deprecated": false, + "ccEnableArenas": true, + "objcClassPrefix": "GPB", + "csharpNamespace": "Google.Protobuf.WellKnownTypes", + "swiftPrefix": "", + "phpClassPrefix": "", + "phpNamespace": "", + "phpMetadataNamespace": "", + "rubyPackage": "", + "uninterpretedOption": [], }, - sourceCodeInfo: { - location: [ - { - path: [4, 0], - span: [50, 0, 53, 1], - leadingComments: - ' Wrapper message for `double`.\n\n The JSON representation for `DoubleValue` is JSON number.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 0, 2, 0], - span: [52, 2, 19], - leadingComments: ' The double value.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 1], - span: [58, 0, 61, 1], - leadingComments: - ' Wrapper message for `float`.\n\n The JSON representation for `FloatValue` is JSON number.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 1, 2, 0], - span: [60, 2, 18], - leadingComments: ' The float value.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 2], - span: [66, 0, 69, 1], - leadingComments: - ' Wrapper message for `int64`.\n\n The JSON representation for `Int64Value` is JSON string.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 2, 2, 0], - span: [68, 2, 18], - leadingComments: ' The int64 value.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 3], - span: [74, 0, 77, 1], - leadingComments: - ' Wrapper message for `uint64`.\n\n The JSON representation for `UInt64Value` is JSON string.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 3, 2, 0], - span: [76, 2, 19], - leadingComments: ' The uint64 value.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4], - span: [82, 0, 85, 1], - leadingComments: - ' Wrapper message for `int32`.\n\n The JSON representation for `Int32Value` is JSON number.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 2, 0], - span: [84, 2, 18], - leadingComments: ' The int32 value.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 5], - span: [90, 0, 93, 1], - leadingComments: - ' Wrapper message for `uint32`.\n\n The JSON representation for `UInt32Value` is JSON number.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 5, 2, 0], - span: [92, 2, 19], - leadingComments: ' The uint32 value.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 6], - span: [98, 0, 101, 1], - leadingComments: - ' Wrapper message for `bool`.\n\n The JSON representation for `BoolValue` is JSON `true` and `false`.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 6, 2, 0], - span: [100, 2, 17], - leadingComments: ' The bool value.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 7], - span: [106, 0, 109, 1], - leadingComments: - ' Wrapper message for `string`.\n\n The JSON representation for `StringValue` is JSON string.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 7, 2, 0], - span: [108, 2, 19], - leadingComments: ' The string value.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 8], - span: [114, 0, 117, 1], - leadingComments: - ' Wrapper message for `bytes`.\n\n The JSON representation for `BytesValue` is JSON string.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 8, 2, 0], - span: [116, 2, 18], - leadingComments: ' The bytes value.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - ], + "sourceCodeInfo": { + "location": [{ + "path": [4, 0], + "span": [50, 0, 53, 1], + "leadingComments": + " Wrapper message for `double`.\n\n The JSON representation for `DoubleValue` is JSON number.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 0, 2, 0], + "span": [52, 2, 19], + "leadingComments": " The double value.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 1], + "span": [58, 0, 61, 1], + "leadingComments": + " Wrapper message for `float`.\n\n The JSON representation for `FloatValue` is JSON number.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 1, 2, 0], + "span": [60, 2, 18], + "leadingComments": " The float value.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 2], + "span": [66, 0, 69, 1], + "leadingComments": + " Wrapper message for `int64`.\n\n The JSON representation for `Int64Value` is JSON string.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 2, 2, 0], + "span": [68, 2, 18], + "leadingComments": " The int64 value.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 3], + "span": [74, 0, 77, 1], + "leadingComments": + " Wrapper message for `uint64`.\n\n The JSON representation for `UInt64Value` is JSON string.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 3, 2, 0], + "span": [76, 2, 19], + "leadingComments": " The uint64 value.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4], + "span": [82, 0, 85, 1], + "leadingComments": + " Wrapper message for `int32`.\n\n The JSON representation for `Int32Value` is JSON number.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 2, 0], + "span": [84, 2, 18], + "leadingComments": " The int32 value.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 5], + "span": [90, 0, 93, 1], + "leadingComments": + " Wrapper message for `uint32`.\n\n The JSON representation for `UInt32Value` is JSON number.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 5, 2, 0], + "span": [92, 2, 19], + "leadingComments": " The uint32 value.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 6], + "span": [98, 0, 101, 1], + "leadingComments": + " Wrapper message for `bool`.\n\n The JSON representation for `BoolValue` is JSON `true` and `false`.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 6, 2, 0], + "span": [100, 2, 17], + "leadingComments": " The bool value.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 7], + "span": [106, 0, 109, 1], + "leadingComments": + " Wrapper message for `string`.\n\n The JSON representation for `StringValue` is JSON string.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 7, 2, 0], + "span": [108, 2, 19], + "leadingComments": " The string value.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 8], + "span": [114, 0, 117, 1], + "leadingComments": + " Wrapper message for `bytes`.\n\n The JSON representation for `BytesValue` is JSON string.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 8, 2, 0], + "span": [116, 2, 18], + "leadingComments": " The bytes value.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }], }, - syntax: 'proto3', + "syntax": "proto3", }), references: { - '.google.protobuf.DoubleValue': DoubleValue, - '.google.protobuf.FloatValue': FloatValue, - '.google.protobuf.Int64Value': Int64Value, - '.google.protobuf.UInt64Value': UInt64Value, - '.google.protobuf.Int32Value': Int32Value, - '.google.protobuf.UInt32Value': UInt32Value, - '.google.protobuf.BoolValue': BoolValue, - '.google.protobuf.StringValue': StringValue, - '.google.protobuf.BytesValue': BytesValue, + ".google.protobuf.DoubleValue": DoubleValue, + ".google.protobuf.FloatValue": FloatValue, + ".google.protobuf.Int64Value": Int64Value, + ".google.protobuf.UInt64Value": UInt64Value, + ".google.protobuf.Int32Value": Int32Value, + ".google.protobuf.UInt32Value": UInt32Value, + ".google.protobuf.BoolValue": BoolValue, + ".google.protobuf.StringValue": StringValue, + ".google.protobuf.BytesValue": BytesValue, }, dependencies: [], }; @@ -833,16 +776,24 @@ 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'; + 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 longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/meta-typings/google/type/date.ts b/integration/meta-typings/google/type/date.ts index 1bd406c2a..0c780991d 100644 --- a/integration/meta-typings/google/type/date.ts +++ b/integration/meta-typings/google/type/date.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { FileDescriptorProto } from 'ts-proto-descriptors'; -import * as _m0 from 'protobufjs/minimal'; +import { FileDescriptorProto } from "ts-proto-descriptors"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.type'; +export const protobufPackage = "google.type"; /** * Represents a whole or partial calendar date, e.g. a birthday. The time of day @@ -92,147 +92,126 @@ export interface ProtoMetadata { options?: { options?: { [key: string]: any }; services?: { - [key: string]: { - options?: { [key: string]: any }; - methods?: { [key: string]: { [key: string]: any } }; - }; - }; - messages?: { - [key: string]: ProtoMetaMessageOptions; - }; - enums?: { - [key: string]: { - options?: { [key: string]: any }; - values?: { [key: string]: { [key: string]: any } }; - }; + [key: string]: { options?: { [key: string]: any }; methods?: { [key: string]: { [key: string]: any } } }; }; + messages?: { [key: string]: ProtoMetaMessageOptions }; + enums?: { [key: string]: { options?: { [key: string]: any }; values?: { [key: string]: { [key: string]: any } } } }; }; } export const protoMetadata: ProtoMetadata = { fileDescriptor: FileDescriptorProto.fromPartial({ - name: 'google/type/date.proto', - package: 'google.type', - dependency: [], - publicDependency: [], - weakDependency: [], - messageType: [ - { - name: 'Date', - field: [ - { - name: 'year', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'year', - options: undefined, - proto3Optional: false, - }, - { - name: 'month', - number: 2, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'month', - options: undefined, - proto3Optional: false, - }, - { - name: 'day', - number: 3, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'day', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - service: [], - extension: [], - options: { - javaPackage: 'com.google.type', - javaOuterClassname: 'DateProto', - javaMultipleFiles: true, - javaGenerateEqualsAndHash: false, - javaStringCheckUtf8: false, - optimizeFor: 1, - goPackage: 'google.golang.org/genproto/googleapis/type/date;date', - ccGenericServices: false, - javaGenericServices: false, - pyGenericServices: false, - phpGenericServices: false, - deprecated: false, - ccEnableArenas: true, - objcClassPrefix: 'GTP', - csharpNamespace: '', - swiftPrefix: '', - phpClassPrefix: '', - phpNamespace: '', - phpMetadataNamespace: '', - rubyPackage: '', - uninterpretedOption: [], + "name": "google/type/date.proto", + "package": "google.type", + "dependency": [], + "publicDependency": [], + "weakDependency": [], + "messageType": [{ + "name": "Date", + "field": [{ + "name": "year", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "year", + "options": undefined, + "proto3Optional": false, + }, { + "name": "month", + "number": 2, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "month", + "options": undefined, + "proto3Optional": false, + }, { + "name": "day", + "number": 3, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "day", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "service": [], + "extension": [], + "options": { + "javaPackage": "com.google.type", + "javaOuterClassname": "DateProto", + "javaMultipleFiles": true, + "javaGenerateEqualsAndHash": false, + "javaStringCheckUtf8": false, + "optimizeFor": 1, + "goPackage": "google.golang.org/genproto/googleapis/type/date;date", + "ccGenericServices": false, + "javaGenericServices": false, + "pyGenericServices": false, + "phpGenericServices": false, + "deprecated": false, + "ccEnableArenas": true, + "objcClassPrefix": "GTP", + "csharpNamespace": "", + "swiftPrefix": "", + "phpClassPrefix": "", + "phpNamespace": "", + "phpMetadataNamespace": "", + "rubyPackage": "", + "uninterpretedOption": [], }, - sourceCodeInfo: { - location: [ - { - path: [4, 0], - span: [36, 0, 49, 1], - leadingComments: - ' Represents a whole or partial calendar date, e.g. a birthday. The time of day\n and time zone are either specified elsewhere or are not significant. The date\n is relative to the Proleptic Gregorian Calendar. This can represent:\n\n * A full date, with non-zero year, month and day values\n * A month and day value, with a zero year, e.g. an anniversary\n * A year on its own, with zero month and day values\n * A year and month value, with a zero day, e.g. a credit card expiration date\n\n Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 0, 2, 0], - span: [39, 2, 17], - leadingComments: ' Year of date. Must be from 1 to 9999, or 0 if specifying a date without\n a year.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 0, 2, 1], - span: [43, 2, 18], - leadingComments: - ' Month of year. Must be from 1 to 12, or 0 if specifying a year without a\n month and day.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 0, 2, 2], - span: [48, 2, 16], - leadingComments: - ' Day of month. Must be from 1 to 31 and valid for the year and month, or 0\n if specifying a year by itself or a year and month where the day is not\n significant.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - ], + "sourceCodeInfo": { + "location": [{ + "path": [4, 0], + "span": [36, 0, 49, 1], + "leadingComments": + " Represents a whole or partial calendar date, e.g. a birthday. The time of day\n and time zone are either specified elsewhere or are not significant. The date\n is relative to the Proleptic Gregorian Calendar. This can represent:\n\n * A full date, with non-zero year, month and day values\n * A month and day value, with a zero year, e.g. an anniversary\n * A year on its own, with zero month and day values\n * A year and month value, with a zero day, e.g. a credit card expiration date\n\n Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 0, 2, 0], + "span": [39, 2, 17], + "leadingComments": " Year of date. Must be from 1 to 9999, or 0 if specifying a date without\n a year.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 0, 2, 1], + "span": [43, 2, 18], + "leadingComments": + " Month of year. Must be from 1 to 12, or 0 if specifying a year without a\n month and day.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 0, 2, 2], + "span": [48, 2, 16], + "leadingComments": + " Day of month. Must be from 1 to 31 and valid for the year and month, or 0\n if specifying a year by itself or a year and month where the day is not\n significant.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }], }, - syntax: 'proto3', + "syntax": "proto3", }), - references: { '.google.type.DateMessage': DateMessage }, + references: { ".google.type.DateMessage": DateMessage }, dependencies: [], }; diff --git a/integration/meta-typings/import_dir/thing.ts b/integration/meta-typings/import_dir/thing.ts index 2c0b16283..51b470782 100644 --- a/integration/meta-typings/import_dir/thing.ts +++ b/integration/meta-typings/import_dir/thing.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { FileDescriptorProto } from 'ts-proto-descriptors'; -import { protoMetadata as protoMetadata1, Timestamp } from '../google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; +import { FileDescriptorProto } from "ts-proto-descriptors"; +import { protoMetadata as protoMetadata1, Timestamp } from "../google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface ImportedThing { createdAt: Date | undefined; @@ -54,66 +54,52 @@ export interface ProtoMetadata { options?: { options?: { [key: string]: any }; services?: { - [key: string]: { - options?: { [key: string]: any }; - methods?: { [key: string]: { [key: string]: any } }; - }; - }; - messages?: { - [key: string]: ProtoMetaMessageOptions; - }; - enums?: { - [key: string]: { - options?: { [key: string]: any }; - values?: { [key: string]: { [key: string]: any } }; - }; + [key: string]: { options?: { [key: string]: any }; methods?: { [key: string]: { [key: string]: any } } }; }; + messages?: { [key: string]: ProtoMetaMessageOptions }; + enums?: { [key: string]: { options?: { [key: string]: any }; values?: { [key: string]: { [key: string]: any } } } }; }; } export const protoMetadata: ProtoMetadata = { fileDescriptor: FileDescriptorProto.fromPartial({ - name: 'import_dir/thing.proto', - package: 'simple', - dependency: ['google/protobuf/timestamp.proto'], - publicDependency: [], - weakDependency: [], - messageType: [ - { - name: 'ImportedThing', - field: [ - { - name: 'created_at', - number: 1, - label: 1, - type: 11, - typeName: '.google.protobuf.Timestamp', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'createdAt', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - service: [], - extension: [], - options: undefined, - sourceCodeInfo: { location: [] }, - syntax: 'proto3', + "name": "import_dir/thing.proto", + "package": "simple", + "dependency": ["google/protobuf/timestamp.proto"], + "publicDependency": [], + "weakDependency": [], + "messageType": [{ + "name": "ImportedThing", + "field": [{ + "name": "created_at", + "number": 1, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.Timestamp", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "createdAt", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "service": [], + "extension": [], + "options": undefined, + "sourceCodeInfo": { "location": [] }, + "syntax": "proto3", }), - references: { '.simple.ImportedThing': ImportedThing }, + references: { ".simple.ImportedThing": ImportedThing }, dependencies: [protoMetadata1], }; diff --git a/integration/meta-typings/simple.ts b/integration/meta-typings/simple.ts index 75c694ac1..79732ab80 100644 --- a/integration/meta-typings/simple.ts +++ b/integration/meta-typings/simple.ts @@ -1,13 +1,13 @@ /* eslint-disable */ -import { FileDescriptorProto } from 'ts-proto-descriptors'; -import { protoMetadata as protoMetadata1, DateMessage } from './google/type/date'; -import { protoMetadata as protoMetadata2, StringValue, Int32Value, BoolValue } from './google/protobuf/wrappers'; -import { protoMetadata as protoMetadata3, Timestamp } from './google/protobuf/timestamp'; -import { protoMetadata as protoMetadata4, ImportedThing } from './import_dir/thing'; -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import { FileDescriptorProto } from "ts-proto-descriptors"; +import { DateMessage, protoMetadata as protoMetadata1 } from "./google/type/date"; +import { BoolValue, Int32Value, protoMetadata as protoMetadata2, StringValue } from "./google/protobuf/wrappers"; +import { protoMetadata as protoMetadata3, Timestamp } from "./google/protobuf/timestamp"; +import { ImportedThing, protoMetadata as protoMetadata4 } from "./import_dir/thing"; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; /** * Adding a comment to the syntax will become the first @@ -171,23 +171,30 @@ export interface Numbers { /** For testing proto3's field presence feature. */ export interface SimpleButOptional { /** Name field */ - name?: string | undefined; + name?: + | string + | undefined; /** Age */ - age?: number | undefined; + age?: + | number + | undefined; /** This comment will also attach */ createdAt?: Date | undefined; child?: Child | undefined; - state?: StateEnum | undefined; + state?: + | StateEnum + | undefined; /** A thing (imported from thing) */ thing?: ImportedThing | undefined; birthday?: DateMessage | undefined; } -export interface Empty {} +export interface Empty { +} function createBaseSimple(): Simple { return { - name: '', + name: "", age: 0, createdAt: undefined, child: undefined, @@ -205,7 +212,7 @@ function createBaseSimple(): Simple { export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== 0) { @@ -321,12 +328,12 @@ export const Simple = { }; function createBaseChild(): Child { - return { name: '', type: 0 }; + return { name: "", type: 0 }; } export const Child = { encode(message: Child, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.type !== 0) { @@ -358,12 +365,12 @@ export const Child = { }; function createBaseNested(): Nested { - return { name: '', message: undefined, state: 0 }; + return { name: "", message: undefined, state: 0 }; } export const Nested = { encode(message: Nested, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.message !== undefined) { @@ -401,12 +408,12 @@ export const Nested = { }; function createBaseNested_InnerMessage(): Nested_InnerMessage { - return { name: '', deep: undefined }; + return { name: "", deep: undefined }; } export const Nested_InnerMessage = { encode(message: Nested_InnerMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.deep !== undefined) { @@ -438,12 +445,12 @@ export const Nested_InnerMessage = { }; function createBaseNested_InnerMessage_DeepMessage(): Nested_InnerMessage_DeepMessage { - return { name: '' }; + return { name: "" }; } export const Nested_InnerMessage_DeepMessage = { encode(message: Nested_InnerMessage_DeepMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -699,15 +706,15 @@ export const SimpleWithMap_EntitiesByIdEntry = { }; function createBaseSimpleWithMap_NameLookupEntry(): SimpleWithMap_NameLookupEntry { - return { key: '', value: '' }; + return { key: "", value: "" }; } export const SimpleWithMap_NameLookupEntry = { encode(message: SimpleWithMap_NameLookupEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -773,12 +780,12 @@ export const SimpleWithMap_IntLookupEntry = { }; function createBaseSimpleWithMap_MapOfTimestampsEntry(): SimpleWithMap_MapOfTimestampsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const SimpleWithMap_MapOfTimestampsEntry = { encode(message: SimpleWithMap_MapOfTimestampsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -810,12 +817,12 @@ export const SimpleWithMap_MapOfTimestampsEntry = { }; function createBaseSimpleWithMap_MapOfBytesEntry(): SimpleWithMap_MapOfBytesEntry { - return { key: '', value: new Uint8Array() }; + return { key: "", value: new Uint8Array() }; } export const SimpleWithMap_MapOfBytesEntry = { encode(message: SimpleWithMap_MapOfBytesEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value.length !== 0) { @@ -989,12 +996,12 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { }; function createBasePingRequest(): PingRequest { - return { input: '' }; + return { input: "" }; } export const PingRequest = { encode(message: PingRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.input !== '') { + if (message.input !== "") { writer.uint32(10).string(message.input); } return writer; @@ -1020,12 +1027,12 @@ export const PingRequest = { }; function createBasePingResponse(): PingResponse { - return { output: '' }; + return { output: "" }; } export const PingResponse = { encode(message: PingResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.output !== '') { + if (message.output !== "") { writer.uint32(10).string(message.output); } return writer; @@ -1272,7 +1279,7 @@ export class PingServiceClientImpl implements PingService { } ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); - const promise = this.rpc.request('simple.PingService', 'ping', data); + const promise = this.rpc.request("simple.PingService", "ping", data); return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); } } @@ -1295,1489 +1302,1334 @@ export interface ProtoMetadata { options?: { options?: { [key: string]: any }; services?: { - [key: string]: { - options?: { [key: string]: any }; - methods?: { [key: string]: { [key: string]: any } }; - }; - }; - messages?: { - [key: string]: ProtoMetaMessageOptions; - }; - enums?: { - [key: string]: { - options?: { [key: string]: any }; - values?: { [key: string]: { [key: string]: any } }; - }; + [key: string]: { options?: { [key: string]: any }; methods?: { [key: string]: { [key: string]: any } } }; }; + messages?: { [key: string]: ProtoMetaMessageOptions }; + enums?: { [key: string]: { options?: { [key: string]: any }; values?: { [key: string]: { [key: string]: any } } } }; }; } export const protoMetadata: ProtoMetadata = { fileDescriptor: FileDescriptorProto.fromPartial({ - name: 'simple.proto', - package: 'simple', - dependency: [ - 'google/type/date.proto', - 'google/protobuf/wrappers.proto', - 'google/protobuf/timestamp.proto', - 'import_dir/thing.proto', - ], - publicDependency: [], - weakDependency: [], - messageType: [ - { - name: 'Simple', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'age', - number: 2, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'age', - options: undefined, - proto3Optional: false, - }, - { - name: 'created_at', - number: 9, - label: 1, - type: 11, - typeName: '.google.protobuf.Timestamp', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'createdAt', - options: undefined, - proto3Optional: false, - }, - { - name: 'child', - number: 3, - label: 1, - type: 11, - typeName: '.simple.Child', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'child', - options: undefined, - proto3Optional: false, - }, - { - name: 'state', - number: 4, - label: 1, - type: 14, - typeName: '.simple.StateEnum', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'state', - options: undefined, - proto3Optional: false, - }, - { - name: 'grand_children', - number: 5, - label: 3, - type: 11, - typeName: '.simple.Child', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'grandChildren', - options: undefined, - proto3Optional: false, - }, - { - name: 'coins', - number: 6, - label: 3, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'coins', - options: undefined, - proto3Optional: false, - }, - { - name: 'snacks', - number: 7, - label: 3, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'snacks', - options: undefined, - proto3Optional: false, - }, - { - name: 'old_states', - number: 8, - label: 3, - type: 14, - typeName: '.simple.StateEnum', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'oldStates', - options: undefined, - proto3Optional: false, - }, - { - name: 'thing', - number: 10, - label: 1, - type: 11, - typeName: '.simple.ImportedThing', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'thing', - options: undefined, - proto3Optional: false, - }, - { - name: 'blobs', - number: 11, - label: 3, - type: 12, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'blobs', - options: undefined, - proto3Optional: false, - }, - { - name: 'birthday', - number: 12, - label: 1, - type: 11, - typeName: '.google.type.Date', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'birthday', - options: undefined, - proto3Optional: false, - }, - { - name: 'blob', - number: 13, - label: 1, - type: 12, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'blob', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'Child', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'type', - number: 2, - label: 1, - type: 14, - typeName: '.simple.Child.Type', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'type', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [ - { - name: 'Type', - value: [ - { name: 'UNKNOWN', number: 0, options: undefined }, - { name: 'GOOD', number: 1, options: undefined }, - { name: 'BAD', number: 2, options: undefined }, - ], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'Nested', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'message', - number: 2, - label: 1, - type: 11, - typeName: '.simple.Nested.InnerMessage', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'message', - options: undefined, - proto3Optional: false, - }, - { - name: 'state', - number: 3, - label: 1, - type: 14, - typeName: '.simple.Nested.InnerEnum', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'state', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [ - { - name: 'InnerMessage', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'deep', - number: 2, - label: 1, - type: 11, - typeName: '.simple.Nested.InnerMessage.DeepMessage', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'deep', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [ - { - name: 'DeepMessage', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [ - { - name: 'InnerEnum', - value: [ - { name: 'UNKNOWN_INNER', number: 0, options: undefined }, - { name: 'GOOD', number: 100, options: undefined }, - { name: 'BAD', number: 1000, options: undefined }, - ], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'OneOfMessage', - field: [ - { - name: 'first', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'first', - options: undefined, - proto3Optional: false, - }, - { - name: 'last', - number: 2, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'last', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [{ name: 'name_fields', options: undefined }], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'SimpleWithWrappers', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 11, - typeName: '.google.protobuf.StringValue', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'age', - number: 2, - label: 1, - type: 11, - typeName: '.google.protobuf.Int32Value', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'age', - options: undefined, - proto3Optional: false, - }, - { - name: 'enabled', - number: 3, - label: 1, - type: 11, - typeName: '.google.protobuf.BoolValue', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'enabled', - options: undefined, - proto3Optional: false, - }, - { - name: 'coins', - number: 6, - label: 3, - type: 11, - typeName: '.google.protobuf.Int32Value', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'coins', - options: undefined, - proto3Optional: false, - }, - { - name: 'snacks', - number: 7, - label: 3, - type: 11, - typeName: '.google.protobuf.StringValue', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'snacks', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'Entity', - field: [ - { - name: 'id', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'id', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'SimpleWithMap', - field: [ - { - name: 'entitiesById', - number: 1, - label: 3, - type: 11, - typeName: '.simple.SimpleWithMap.EntitiesByIdEntry', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'entitiesById', - options: undefined, - proto3Optional: false, - }, - { - name: 'nameLookup', - number: 2, - label: 3, - type: 11, - typeName: '.simple.SimpleWithMap.NameLookupEntry', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'nameLookup', - options: undefined, - proto3Optional: false, - }, - { - name: 'intLookup', - number: 3, - label: 3, - type: 11, - typeName: '.simple.SimpleWithMap.IntLookupEntry', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'intLookup', - options: undefined, - proto3Optional: false, - }, - { - name: 'mapOfTimestamps', - number: 4, - label: 3, - type: 11, - typeName: '.simple.SimpleWithMap.MapOfTimestampsEntry', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'mapOfTimestamps', - options: undefined, - proto3Optional: false, - }, - { - name: 'mapOfBytes', - number: 5, - label: 3, - type: 11, - typeName: '.simple.SimpleWithMap.MapOfBytesEntry', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'mapOfBytes', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [ - { - name: 'EntitiesByIdEntry', - field: [ - { - name: 'key', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'key', - options: undefined, - proto3Optional: false, - }, - { - name: 'value', - number: 2, - label: 1, - type: 11, - typeName: '.simple.Entity', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: { - messageSetWireFormat: false, - noStandardDescriptorAccessor: false, - deprecated: false, - mapEntry: true, - uninterpretedOption: [], - }, - reservedRange: [], - reservedName: [], - }, - { - name: 'NameLookupEntry', - field: [ - { - name: 'key', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'key', - options: undefined, - proto3Optional: false, - }, - { - name: 'value', - number: 2, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: { - messageSetWireFormat: false, - noStandardDescriptorAccessor: false, - deprecated: false, - mapEntry: true, - uninterpretedOption: [], - }, - reservedRange: [], - reservedName: [], - }, - { - name: 'IntLookupEntry', - field: [ - { - name: 'key', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'key', - options: undefined, - proto3Optional: false, - }, - { - name: 'value', - number: 2, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: { - messageSetWireFormat: false, - noStandardDescriptorAccessor: false, - deprecated: false, - mapEntry: true, - uninterpretedOption: [], - }, - reservedRange: [], - reservedName: [], - }, - { - name: 'MapOfTimestampsEntry', - field: [ - { - name: 'key', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'key', - options: undefined, - proto3Optional: false, - }, - { - name: 'value', - number: 2, - label: 1, - type: 11, - typeName: '.google.protobuf.Timestamp', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: { - messageSetWireFormat: false, - noStandardDescriptorAccessor: false, - deprecated: false, - mapEntry: true, - uninterpretedOption: [], - }, - reservedRange: [], - reservedName: [], - }, - { - name: 'MapOfBytesEntry', - field: [ - { - name: 'key', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'key', - options: undefined, - proto3Optional: false, - }, - { - name: 'value', - number: 2, - label: 1, - type: 12, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: { - messageSetWireFormat: false, - noStandardDescriptorAccessor: false, - deprecated: false, - mapEntry: true, - uninterpretedOption: [], - }, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'SimpleWithSnakeCaseMap', - field: [ - { - name: 'entities_by_id', - number: 1, - label: 3, - type: 11, - typeName: '.simple.SimpleWithSnakeCaseMap.EntitiesByIdEntry', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'entitiesById', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [ - { - name: 'EntitiesByIdEntry', - field: [ - { - name: 'key', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'key', - options: undefined, - proto3Optional: false, - }, - { - name: 'value', - number: 2, - label: 1, - type: 11, - typeName: '.simple.Entity', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: { - messageSetWireFormat: false, - noStandardDescriptorAccessor: false, - deprecated: false, - mapEntry: true, - uninterpretedOption: [], - }, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'SimpleWithMapOfEnums', - field: [ - { - name: 'enums_by_id', - number: 1, - label: 3, - type: 11, - typeName: '.simple.SimpleWithMapOfEnums.EnumsByIdEntry', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'enumsById', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [ - { - name: 'EnumsByIdEntry', - field: [ - { - name: 'key', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'key', - options: undefined, - proto3Optional: false, - }, - { - name: 'value', - number: 2, - label: 1, - type: 14, - typeName: '.simple.StateEnum', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: { - messageSetWireFormat: false, - noStandardDescriptorAccessor: false, - deprecated: false, - mapEntry: true, - uninterpretedOption: [], - }, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'PingRequest', - field: [ - { - name: 'input', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'input', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'PingResponse', - field: [ - { - name: 'output', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'output', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'Numbers', - field: [ - { - name: 'double', - number: 1, - label: 1, - type: 1, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'double', - options: undefined, - proto3Optional: false, - }, - { - name: 'float', - number: 2, - label: 1, - type: 2, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'float', - options: undefined, - proto3Optional: false, - }, - { - name: 'int32', - number: 3, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'int32', - options: undefined, - proto3Optional: false, - }, - { - name: 'int64', - number: 4, - label: 1, - type: 3, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'int64', - options: undefined, - proto3Optional: false, - }, - { - name: 'uint32', - number: 5, - label: 1, - type: 13, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uint32', - options: undefined, - proto3Optional: false, - }, - { - name: 'uint64', - number: 6, - label: 1, - type: 4, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uint64', - options: undefined, - proto3Optional: false, - }, - { - name: 'sint32', - number: 7, - label: 1, - type: 17, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'sint32', - options: undefined, - proto3Optional: false, - }, - { - name: 'sint64', - number: 8, - label: 1, - type: 18, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'sint64', - options: undefined, - proto3Optional: false, - }, - { - name: 'fixed32', - number: 9, - label: 1, - type: 7, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'fixed32', - options: undefined, - proto3Optional: false, - }, - { - name: 'fixed64', - number: 10, - label: 1, - type: 6, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'fixed64', - options: undefined, - proto3Optional: false, - }, - { - name: 'sfixed32', - number: 11, - label: 1, - type: 15, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'sfixed32', - options: undefined, - proto3Optional: false, - }, - { - name: 'sfixed64', - number: 12, - label: 1, - type: 16, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'sfixed64', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'SimpleButOptional', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: true, - }, - { - name: 'age', - number: 2, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 1, - jsonName: 'age', - options: undefined, - proto3Optional: true, - }, - { - name: 'created_at', - number: 9, - label: 1, - type: 11, - typeName: '.google.protobuf.Timestamp', - extendee: '', - defaultValue: '', - oneofIndex: 2, - jsonName: 'createdAt', - options: undefined, - proto3Optional: true, - }, - { - name: 'child', - number: 3, - label: 1, - type: 11, - typeName: '.simple.Child', - extendee: '', - defaultValue: '', - oneofIndex: 3, - jsonName: 'child', - options: undefined, - proto3Optional: true, - }, - { - name: 'state', - number: 4, - label: 1, - type: 14, - typeName: '.simple.StateEnum', - extendee: '', - defaultValue: '', - oneofIndex: 4, - jsonName: 'state', - options: undefined, - proto3Optional: true, - }, - { - name: 'thing', - number: 10, - label: 1, - type: 11, - typeName: '.simple.ImportedThing', - extendee: '', - defaultValue: '', - oneofIndex: 5, - jsonName: 'thing', - options: undefined, - proto3Optional: true, - }, - { - name: 'birthday', - number: 12, - label: 1, - type: 11, - typeName: '.google.type.Date', - extendee: '', - defaultValue: '', - oneofIndex: 6, - jsonName: 'birthday', - options: undefined, - proto3Optional: true, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [ - { name: '_name', options: undefined }, - { name: '_age', options: undefined }, - { name: '_created_at', options: undefined }, - { name: '_child', options: undefined }, - { name: '_state', options: undefined }, - { name: '_thing', options: undefined }, - { name: '_birthday', options: undefined }, - ], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'Empty', - field: [], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, + "name": "simple.proto", + "package": "simple", + "dependency": [ + "google/type/date.proto", + "google/protobuf/wrappers.proto", + "google/protobuf/timestamp.proto", + "import_dir/thing.proto", ], - enumType: [ - { - name: 'StateEnum', - value: [ - { name: 'UNKNOWN', number: 0, options: undefined }, - { name: 'ON', number: 2, options: undefined }, - { name: 'OFF', number: 3, options: undefined }, - ], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - service: [ - { - name: 'PingService', - method: [ - { - name: 'ping', - inputType: '.simple.PingRequest', - outputType: '.simple.PingResponse', - options: undefined, - clientStreaming: false, - serverStreaming: false, - }, - ], - options: undefined, - }, - ], - extension: [], - options: undefined, - sourceCodeInfo: { - location: [ - { - path: [12], - span: [2, 0, 18], - leadingComments: - ' Adding a comment to the syntax will become the first\n comment in the output source file.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 0], - span: [13, 0, 30, 1], - leadingComments: '* Example comment on the Simple message ', - trailingComments: '', - leadingDetachedComments: [ - ' This comment is seperated by a blank non-comment line, and will detatch from \n the following comment on the message Simple.\n', - ], + "publicDependency": [], + "weakDependency": [], + "messageType": [{ + "name": "Simple", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "age", + "number": 2, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "age", + "options": undefined, + "proto3Optional": false, + }, { + "name": "created_at", + "number": 9, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.Timestamp", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "createdAt", + "options": undefined, + "proto3Optional": false, + }, { + "name": "child", + "number": 3, + "label": 1, + "type": 11, + "typeName": ".simple.Child", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "child", + "options": undefined, + "proto3Optional": false, + }, { + "name": "state", + "number": 4, + "label": 1, + "type": 14, + "typeName": ".simple.StateEnum", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "state", + "options": undefined, + "proto3Optional": false, + }, { + "name": "grand_children", + "number": 5, + "label": 3, + "type": 11, + "typeName": ".simple.Child", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "grandChildren", + "options": undefined, + "proto3Optional": false, + }, { + "name": "coins", + "number": 6, + "label": 3, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "coins", + "options": undefined, + "proto3Optional": false, + }, { + "name": "snacks", + "number": 7, + "label": 3, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "snacks", + "options": undefined, + "proto3Optional": false, + }, { + "name": "old_states", + "number": 8, + "label": 3, + "type": 14, + "typeName": ".simple.StateEnum", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "oldStates", + "options": undefined, + "proto3Optional": false, + }, { + "name": "thing", + "number": 10, + "label": 1, + "type": 11, + "typeName": ".simple.ImportedThing", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "thing", + "options": undefined, + "proto3Optional": false, + }, { + "name": "blobs", + "number": 11, + "label": 3, + "type": 12, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "blobs", + "options": undefined, + "proto3Optional": false, + }, { + "name": "birthday", + "number": 12, + "label": 1, + "type": 11, + "typeName": ".google.type.Date", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "birthday", + "options": undefined, + "proto3Optional": false, + }, { + "name": "blob", + "number": 13, + "label": 1, + "type": 12, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "blob", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "Child", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "type", + "number": 2, + "label": 1, + "type": 14, + "typeName": ".simple.Child.Type", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "type", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [{ + "name": "Type", + "value": [{ "name": "UNKNOWN", "number": 0, "options": undefined }, { + "name": "GOOD", + "number": 1, + "options": undefined, + }, { "name": "BAD", "number": 2, "options": undefined }], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "Nested", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "message", + "number": 2, + "label": 1, + "type": 11, + "typeName": ".simple.Nested.InnerMessage", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "message", + "options": undefined, + "proto3Optional": false, + }, { + "name": "state", + "number": 3, + "label": 1, + "type": 14, + "typeName": ".simple.Nested.InnerEnum", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "state", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [{ + "name": "InnerMessage", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "deep", + "number": 2, + "label": 1, + "type": 11, + "typeName": ".simple.Nested.InnerMessage.DeepMessage", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "deep", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [{ + "name": "DeepMessage", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [{ + "name": "InnerEnum", + "value": [{ "name": "UNKNOWN_INNER", "number": 0, "options": undefined }, { + "name": "GOOD", + "number": 100, + "options": undefined, + }, { "name": "BAD", "number": 1000, "options": undefined }], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "OneOfMessage", + "field": [{ + "name": "first", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "first", + "options": undefined, + "proto3Optional": false, + }, { + "name": "last", + "number": 2, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "last", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [{ "name": "name_fields", "options": undefined }], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "SimpleWithWrappers", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.StringValue", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "age", + "number": 2, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.Int32Value", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "age", + "options": undefined, + "proto3Optional": false, + }, { + "name": "enabled", + "number": 3, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.BoolValue", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "enabled", + "options": undefined, + "proto3Optional": false, + }, { + "name": "coins", + "number": 6, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.Int32Value", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "coins", + "options": undefined, + "proto3Optional": false, + }, { + "name": "snacks", + "number": 7, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.StringValue", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "snacks", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "Entity", + "field": [{ + "name": "id", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "id", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "SimpleWithMap", + "field": [{ + "name": "entitiesById", + "number": 1, + "label": 3, + "type": 11, + "typeName": ".simple.SimpleWithMap.EntitiesByIdEntry", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "entitiesById", + "options": undefined, + "proto3Optional": false, + }, { + "name": "nameLookup", + "number": 2, + "label": 3, + "type": 11, + "typeName": ".simple.SimpleWithMap.NameLookupEntry", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "nameLookup", + "options": undefined, + "proto3Optional": false, + }, { + "name": "intLookup", + "number": 3, + "label": 3, + "type": 11, + "typeName": ".simple.SimpleWithMap.IntLookupEntry", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "intLookup", + "options": undefined, + "proto3Optional": false, + }, { + "name": "mapOfTimestamps", + "number": 4, + "label": 3, + "type": 11, + "typeName": ".simple.SimpleWithMap.MapOfTimestampsEntry", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "mapOfTimestamps", + "options": undefined, + "proto3Optional": false, + }, { + "name": "mapOfBytes", + "number": 5, + "label": 3, + "type": 11, + "typeName": ".simple.SimpleWithMap.MapOfBytesEntry", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "mapOfBytes", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [{ + "name": "EntitiesByIdEntry", + "field": [{ + "name": "key", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "key", + "options": undefined, + "proto3Optional": false, + }, { + "name": "value", + "number": 2, + "label": 1, + "type": 11, + "typeName": ".simple.Entity", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": { + "messageSetWireFormat": false, + "noStandardDescriptorAccessor": false, + "deprecated": false, + "mapEntry": true, + "uninterpretedOption": [], }, - { - path: [4, 0, 2, 0], - span: [15, 2, 18], - leadingComments: ' Name field\n', - trailingComments: '', - leadingDetachedComments: [], + "reservedRange": [], + "reservedName": [], + }, { + "name": "NameLookupEntry", + "field": [{ + "name": "key", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "key", + "options": undefined, + "proto3Optional": false, + }, { + "name": "value", + "number": 2, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": { + "messageSetWireFormat": false, + "noStandardDescriptorAccessor": false, + "deprecated": false, + "mapEntry": true, + "uninterpretedOption": [], }, - { - path: [4, 0, 2, 1], - span: [17, 2, 16], - leadingComments: ' Age ', - trailingComments: '', - leadingDetachedComments: [], + "reservedRange": [], + "reservedName": [], + }, { + "name": "IntLookupEntry", + "field": [{ + "name": "key", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "key", + "options": undefined, + "proto3Optional": false, + }, { + "name": "value", + "number": 2, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": { + "messageSetWireFormat": false, + "noStandardDescriptorAccessor": false, + "deprecated": false, + "mapEntry": true, + "uninterpretedOption": [], }, - { - path: [4, 0, 2, 2], - span: [18, 2, 43], - leadingComments: '', - trailingComments: ' This comment will also attach\n', - leadingDetachedComments: [], + "reservedRange": [], + "reservedName": [], + }, { + "name": "MapOfTimestampsEntry", + "field": [{ + "name": "key", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "key", + "options": undefined, + "proto3Optional": false, + }, { + "name": "value", + "number": 2, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.Timestamp", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": { + "messageSetWireFormat": false, + "noStandardDescriptorAccessor": false, + "deprecated": false, + "mapEntry": true, + "uninterpretedOption": [], }, - { - path: [4, 0, 2, 9], - span: [26, 2, 27], - leadingComments: ' A thing (imported from thing)\n', - trailingComments: '', - leadingDetachedComments: [], + "reservedRange": [], + "reservedName": [], + }, { + "name": "MapOfBytesEntry", + "field": [{ + "name": "key", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "key", + "options": undefined, + "proto3Optional": false, + }, { + "name": "value", + "number": 2, + "label": 1, + "type": 12, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": { + "messageSetWireFormat": false, + "noStandardDescriptorAccessor": false, + "deprecated": false, + "mapEntry": true, + "uninterpretedOption": [], }, - { - path: [4, 2, 3, 0], - span: [54, 2, 61, 3], - leadingComments: ' Comment for a nested message */\n', - trailingComments: '', - leadingDetachedComments: [], + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "SimpleWithSnakeCaseMap", + "field": [{ + "name": "entities_by_id", + "number": 1, + "label": 3, + "type": 11, + "typeName": ".simple.SimpleWithSnakeCaseMap.EntitiesByIdEntry", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "entitiesById", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [{ + "name": "EntitiesByIdEntry", + "field": [{ + "name": "key", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "key", + "options": undefined, + "proto3Optional": false, + }, { + "name": "value", + "number": 2, + "label": 1, + "type": 11, + "typeName": ".simple.Entity", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": { + "messageSetWireFormat": false, + "noStandardDescriptorAccessor": false, + "deprecated": false, + "mapEntry": true, + "uninterpretedOption": [], }, - { - path: [4, 12], - span: [133, 0, 144, 1], - leadingComments: "* For testing proto3's field presence feature. ", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 0], - span: [135, 2, 27], - leadingComments: ' Name field\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 1], - span: [137, 2, 25], - leadingComments: ' Age ', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 2], - span: [138, 2, 52], - leadingComments: '', - trailingComments: ' This comment will also attach\n', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 5], - span: [142, 2, 36], - leadingComments: ' A thing (imported from thing)\n', - trailingComments: '', - leadingDetachedComments: [], + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "SimpleWithMapOfEnums", + "field": [{ + "name": "enums_by_id", + "number": 1, + "label": 3, + "type": 11, + "typeName": ".simple.SimpleWithMapOfEnums.EnumsByIdEntry", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "enumsById", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [{ + "name": "EnumsByIdEntry", + "field": [{ + "name": "key", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "key", + "options": undefined, + "proto3Optional": false, + }, { + "name": "value", + "number": 2, + "label": 1, + "type": 14, + "typeName": ".simple.StateEnum", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": { + "messageSetWireFormat": false, + "noStandardDescriptorAccessor": false, + "deprecated": false, + "mapEntry": true, + "uninterpretedOption": [], }, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "PingRequest", + "field": [{ + "name": "input", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "input", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "PingResponse", + "field": [{ + "name": "output", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "output", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "Numbers", + "field": [{ + "name": "double", + "number": 1, + "label": 1, + "type": 1, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "double", + "options": undefined, + "proto3Optional": false, + }, { + "name": "float", + "number": 2, + "label": 1, + "type": 2, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "float", + "options": undefined, + "proto3Optional": false, + }, { + "name": "int32", + "number": 3, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "int32", + "options": undefined, + "proto3Optional": false, + }, { + "name": "int64", + "number": 4, + "label": 1, + "type": 3, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "int64", + "options": undefined, + "proto3Optional": false, + }, { + "name": "uint32", + "number": 5, + "label": 1, + "type": 13, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uint32", + "options": undefined, + "proto3Optional": false, + }, { + "name": "uint64", + "number": 6, + "label": 1, + "type": 4, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uint64", + "options": undefined, + "proto3Optional": false, + }, { + "name": "sint32", + "number": 7, + "label": 1, + "type": 17, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "sint32", + "options": undefined, + "proto3Optional": false, + }, { + "name": "sint64", + "number": 8, + "label": 1, + "type": 18, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "sint64", + "options": undefined, + "proto3Optional": false, + }, { + "name": "fixed32", + "number": 9, + "label": 1, + "type": 7, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "fixed32", + "options": undefined, + "proto3Optional": false, + }, { + "name": "fixed64", + "number": 10, + "label": 1, + "type": 6, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "fixed64", + "options": undefined, + "proto3Optional": false, + }, { + "name": "sfixed32", + "number": 11, + "label": 1, + "type": 15, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "sfixed32", + "options": undefined, + "proto3Optional": false, + }, { + "name": "sfixed64", + "number": 12, + "label": 1, + "type": 16, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "sfixed64", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "SimpleButOptional", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": true, + }, { + "name": "age", + "number": 2, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 1, + "jsonName": "age", + "options": undefined, + "proto3Optional": true, + }, { + "name": "created_at", + "number": 9, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.Timestamp", + "extendee": "", + "defaultValue": "", + "oneofIndex": 2, + "jsonName": "createdAt", + "options": undefined, + "proto3Optional": true, + }, { + "name": "child", + "number": 3, + "label": 1, + "type": 11, + "typeName": ".simple.Child", + "extendee": "", + "defaultValue": "", + "oneofIndex": 3, + "jsonName": "child", + "options": undefined, + "proto3Optional": true, + }, { + "name": "state", + "number": 4, + "label": 1, + "type": 14, + "typeName": ".simple.StateEnum", + "extendee": "", + "defaultValue": "", + "oneofIndex": 4, + "jsonName": "state", + "options": undefined, + "proto3Optional": true, + }, { + "name": "thing", + "number": 10, + "label": 1, + "type": 11, + "typeName": ".simple.ImportedThing", + "extendee": "", + "defaultValue": "", + "oneofIndex": 5, + "jsonName": "thing", + "options": undefined, + "proto3Optional": true, + }, { + "name": "birthday", + "number": 12, + "label": 1, + "type": 11, + "typeName": ".google.type.Date", + "extendee": "", + "defaultValue": "", + "oneofIndex": 6, + "jsonName": "birthday", + "options": undefined, + "proto3Optional": true, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [ + { "name": "_name", "options": undefined }, + { "name": "_age", "options": undefined }, + { "name": "_created_at", "options": undefined }, + { "name": "_child", "options": undefined }, + { "name": "_state", "options": undefined }, + { "name": "_thing", "options": undefined }, + { "name": "_birthday", "options": undefined }, ], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "Empty", + "field": [], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [{ + "name": "StateEnum", + "value": [{ "name": "UNKNOWN", "number": 0, "options": undefined }, { + "name": "ON", + "number": 2, + "options": undefined, + }, { "name": "OFF", "number": 3, "options": undefined }], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "service": [{ + "name": "PingService", + "method": [{ + "name": "ping", + "inputType": ".simple.PingRequest", + "outputType": ".simple.PingResponse", + "options": undefined, + "clientStreaming": false, + "serverStreaming": false, + }], + "options": undefined, + }], + "extension": [], + "options": undefined, + "sourceCodeInfo": { + "location": [{ + "path": [12], + "span": [2, 0, 18], + "leadingComments": + " Adding a comment to the syntax will become the first\n comment in the output source file.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 0], + "span": [13, 0, 30, 1], + "leadingComments": "* Example comment on the Simple message ", + "trailingComments": "", + "leadingDetachedComments": [ + " This comment is seperated by a blank non-comment line, and will detatch from \n the following comment on the message Simple.\n", + ], + }, { + "path": [4, 0, 2, 0], + "span": [15, 2, 18], + "leadingComments": " Name field\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 0, 2, 1], + "span": [17, 2, 16], + "leadingComments": " Age ", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 0, 2, 2], + "span": [18, 2, 43], + "leadingComments": "", + "trailingComments": " This comment will also attach\n", + "leadingDetachedComments": [], + }, { + "path": [4, 0, 2, 9], + "span": [26, 2, 27], + "leadingComments": " A thing (imported from thing)\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 2, 3, 0], + "span": [54, 2, 61, 3], + "leadingComments": " Comment for a nested message */\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12], + "span": [133, 0, 144, 1], + "leadingComments": "* For testing proto3's field presence feature. ", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 0], + "span": [135, 2, 27], + "leadingComments": " Name field\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 1], + "span": [137, 2, 25], + "leadingComments": " Age ", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 2], + "span": [138, 2, 52], + "leadingComments": "", + "trailingComments": " This comment will also attach\n", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 5], + "span": [142, 2, 36], + "leadingComments": " A thing (imported from thing)\n", + "trailingComments": "", + "leadingDetachedComments": [], + }], }, - syntax: 'proto3', + "syntax": "proto3", }), references: { - '.simple.StateEnum': StateEnum, - '.simple.Simple': Simple, - '.simple.Child': Child, - '.simple.Child.Type': Child_Type, - '.simple.Nested': Nested, - '.simple.Nested.InnerEnum': Nested_InnerEnum, - '.simple.Nested.InnerMessage': Nested_InnerMessage, - '.simple.Nested.InnerMessage.DeepMessage': Nested_InnerMessage_DeepMessage, - '.simple.OneOfMessage': OneOfMessage, - '.simple.SimpleWithWrappers': SimpleWithWrappers, - '.simple.Entity': Entity, - '.simple.SimpleWithMap': SimpleWithMap, - '.simple.SimpleWithMap.EntitiesByIdEntry': SimpleWithMap_EntitiesByIdEntry, - '.simple.SimpleWithMap.NameLookupEntry': SimpleWithMap_NameLookupEntry, - '.simple.SimpleWithMap.IntLookupEntry': SimpleWithMap_IntLookupEntry, - '.simple.SimpleWithMap.MapOfTimestampsEntry': SimpleWithMap_MapOfTimestampsEntry, - '.simple.SimpleWithMap.MapOfBytesEntry': SimpleWithMap_MapOfBytesEntry, - '.simple.SimpleWithSnakeCaseMap': SimpleWithSnakeCaseMap, - '.simple.SimpleWithSnakeCaseMap.EntitiesByIdEntry': SimpleWithSnakeCaseMap_EntitiesByIdEntry, - '.simple.SimpleWithMapOfEnums': SimpleWithMapOfEnums, - '.simple.SimpleWithMapOfEnums.EnumsByIdEntry': SimpleWithMapOfEnums_EnumsByIdEntry, - '.simple.PingRequest': PingRequest, - '.simple.PingResponse': PingResponse, - '.simple.Numbers': Numbers, - '.simple.SimpleButOptional': SimpleButOptional, - '.simple.Empty': Empty, - '.simple.PingService': PingServiceClientImpl, + ".simple.StateEnum": StateEnum, + ".simple.Simple": Simple, + ".simple.Child": Child, + ".simple.Child.Type": Child_Type, + ".simple.Nested": Nested, + ".simple.Nested.InnerEnum": Nested_InnerEnum, + ".simple.Nested.InnerMessage": Nested_InnerMessage, + ".simple.Nested.InnerMessage.DeepMessage": Nested_InnerMessage_DeepMessage, + ".simple.OneOfMessage": OneOfMessage, + ".simple.SimpleWithWrappers": SimpleWithWrappers, + ".simple.Entity": Entity, + ".simple.SimpleWithMap": SimpleWithMap, + ".simple.SimpleWithMap.EntitiesByIdEntry": SimpleWithMap_EntitiesByIdEntry, + ".simple.SimpleWithMap.NameLookupEntry": SimpleWithMap_NameLookupEntry, + ".simple.SimpleWithMap.IntLookupEntry": SimpleWithMap_IntLookupEntry, + ".simple.SimpleWithMap.MapOfTimestampsEntry": SimpleWithMap_MapOfTimestampsEntry, + ".simple.SimpleWithMap.MapOfBytesEntry": SimpleWithMap_MapOfBytesEntry, + ".simple.SimpleWithSnakeCaseMap": SimpleWithSnakeCaseMap, + ".simple.SimpleWithSnakeCaseMap.EntitiesByIdEntry": SimpleWithSnakeCaseMap_EntitiesByIdEntry, + ".simple.SimpleWithMapOfEnums": SimpleWithMapOfEnums, + ".simple.SimpleWithMapOfEnums.EnumsByIdEntry": SimpleWithMapOfEnums_EnumsByIdEntry, + ".simple.PingRequest": PingRequest, + ".simple.PingResponse": PingResponse, + ".simple.Numbers": Numbers, + ".simple.SimpleButOptional": SimpleButOptional, + ".simple.Empty": Empty, + ".simple.PingService": PingServiceClientImpl, }, dependencies: [protoMetadata1, protoMetadata2, protoMetadata3, protoMetadata4], }; @@ -2786,11 +2638,19 @@ 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'; + 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 toTimestamp(date: Date): Timestamp { @@ -2807,7 +2667,7 @@ function fromTimestamp(t: Timestamp): Date { function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/nestjs-metadata-grpc-js/hero.ts b/integration/nestjs-metadata-grpc-js/hero.ts index 6f1c67d35..4c9fdfb00 100644 --- a/integration/nestjs-metadata-grpc-js/hero.ts +++ b/integration/nestjs-metadata-grpc-js/hero.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices'; -import { Metadata } from '@grpc/grpc-js'; -import { Observable } from 'rxjs'; +import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices"; +import { Metadata } from "@grpc/grpc-js"; +import { Observable } from "rxjs"; -export const protobufPackage = 'hero'; +export const protobufPackage = "hero"; export interface HeroById { id: number; @@ -23,7 +23,7 @@ export interface Villain { name: string; } -export const HERO_PACKAGE_NAME = 'hero'; +export const HERO_PACKAGE_NAME = "hero"; export interface HeroServiceClient { findOneHero(request: HeroById, metadata?: Metadata): Observable; @@ -43,17 +43,17 @@ export interface HeroServiceController { export function HeroServiceControllerMethods() { return function (constructor: Function) { - const grpcMethods: string[] = ['findOneHero', 'findOneVillain']; + const grpcMethods: string[] = ["findOneHero", "findOneVillain"]; for (const method of grpcMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } - const grpcStreamMethods: string[] = ['findManyVillain']; + const grpcStreamMethods: string[] = ["findManyVillain"]; for (const method of grpcStreamMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcStreamMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcStreamMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } }; } -export const HERO_SERVICE_NAME = 'HeroService'; +export const HERO_SERVICE_NAME = "HeroService"; diff --git a/integration/nestjs-metadata-observables/hero.ts b/integration/nestjs-metadata-observables/hero.ts index f9cfd75f2..a944a59fa 100644 --- a/integration/nestjs-metadata-observables/hero.ts +++ b/integration/nestjs-metadata-observables/hero.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices'; -import { Metadata } from '@grpc/grpc-js'; -import { Observable } from 'rxjs'; +import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices"; +import { Metadata } from "@grpc/grpc-js"; +import { Observable } from "rxjs"; -export const protobufPackage = 'hero'; +export const protobufPackage = "hero"; export interface HeroById { id: number; @@ -23,7 +23,7 @@ export interface Villain { name: string; } -export const HERO_PACKAGE_NAME = 'hero'; +export const HERO_PACKAGE_NAME = "hero"; export interface HeroServiceClient { findOneHero(request: HeroById, metadata?: Metadata): Observable; @@ -43,17 +43,17 @@ export interface HeroServiceController { export function HeroServiceControllerMethods() { return function (constructor: Function) { - const grpcMethods: string[] = ['findOneHero', 'findOneVillain']; + const grpcMethods: string[] = ["findOneHero", "findOneVillain"]; for (const method of grpcMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } - const grpcStreamMethods: string[] = ['findManyVillain']; + const grpcStreamMethods: string[] = ["findManyVillain"]; for (const method of grpcStreamMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcStreamMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcStreamMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } }; } -export const HERO_SERVICE_NAME = 'HeroService'; +export const HERO_SERVICE_NAME = "HeroService"; diff --git a/integration/nestjs-metadata-restparameters/hero.ts b/integration/nestjs-metadata-restparameters/hero.ts index cd80864ee..ffb3d3d0d 100644 --- a/integration/nestjs-metadata-restparameters/hero.ts +++ b/integration/nestjs-metadata-restparameters/hero.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices'; -import { Metadata } from '@grpc/grpc-js'; -import { Observable } from 'rxjs'; +import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices"; +import { Metadata } from "@grpc/grpc-js"; +import { Observable } from "rxjs"; -export const protobufPackage = 'hero'; +export const protobufPackage = "hero"; export interface HeroById { id: number; @@ -23,7 +23,7 @@ export interface Villain { name: string; } -export const HERO_PACKAGE_NAME = 'hero'; +export const HERO_PACKAGE_NAME = "hero"; export interface HeroServiceClient { findOneHero(request: HeroById, metadata: Metadata, ...rest: any): Observable; @@ -47,17 +47,17 @@ export interface HeroServiceController { export function HeroServiceControllerMethods() { return function (constructor: Function) { - const grpcMethods: string[] = ['findOneHero', 'findOneVillain']; + const grpcMethods: string[] = ["findOneHero", "findOneVillain"]; for (const method of grpcMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } - const grpcStreamMethods: string[] = ['findManyVillain']; + const grpcStreamMethods: string[] = ["findManyVillain"]; for (const method of grpcStreamMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcStreamMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcStreamMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } }; } -export const HERO_SERVICE_NAME = 'HeroService'; +export const HERO_SERVICE_NAME = "HeroService"; diff --git a/integration/nestjs-metadata/hero.ts b/integration/nestjs-metadata/hero.ts index 6f1c67d35..4c9fdfb00 100644 --- a/integration/nestjs-metadata/hero.ts +++ b/integration/nestjs-metadata/hero.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices'; -import { Metadata } from '@grpc/grpc-js'; -import { Observable } from 'rxjs'; +import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices"; +import { Metadata } from "@grpc/grpc-js"; +import { Observable } from "rxjs"; -export const protobufPackage = 'hero'; +export const protobufPackage = "hero"; export interface HeroById { id: number; @@ -23,7 +23,7 @@ export interface Villain { name: string; } -export const HERO_PACKAGE_NAME = 'hero'; +export const HERO_PACKAGE_NAME = "hero"; export interface HeroServiceClient { findOneHero(request: HeroById, metadata?: Metadata): Observable; @@ -43,17 +43,17 @@ export interface HeroServiceController { export function HeroServiceControllerMethods() { return function (constructor: Function) { - const grpcMethods: string[] = ['findOneHero', 'findOneVillain']; + const grpcMethods: string[] = ["findOneHero", "findOneVillain"]; for (const method of grpcMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } - const grpcStreamMethods: string[] = ['findManyVillain']; + const grpcStreamMethods: string[] = ["findManyVillain"]; for (const method of grpcStreamMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcStreamMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcStreamMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } }; } -export const HERO_SERVICE_NAME = 'HeroService'; +export const HERO_SERVICE_NAME = "HeroService"; diff --git a/integration/nestjs-restparameters/hero.ts b/integration/nestjs-restparameters/hero.ts index 92972371b..abf56feb9 100644 --- a/integration/nestjs-restparameters/hero.ts +++ b/integration/nestjs-restparameters/hero.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices'; -import { Observable } from 'rxjs'; +import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices"; +import { Observable } from "rxjs"; -export const protobufPackage = 'hero'; +export const protobufPackage = "hero"; export interface HeroById { id: number; @@ -22,7 +22,7 @@ export interface Villain { name: string; } -export const HERO_PACKAGE_NAME = 'hero'; +export const HERO_PACKAGE_NAME = "hero"; export interface HeroServiceClient { findOneHero(request: HeroById, ...rest: any): Observable; @@ -42,17 +42,17 @@ export interface HeroServiceController { export function HeroServiceControllerMethods() { return function (constructor: Function) { - const grpcMethods: string[] = ['findOneHero', 'findOneVillain']; + const grpcMethods: string[] = ["findOneHero", "findOneVillain"]; for (const method of grpcMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } - const grpcStreamMethods: string[] = ['findManyVillain']; + const grpcStreamMethods: string[] = ["findManyVillain"]; for (const method of grpcStreamMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcStreamMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcStreamMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } }; } -export const HERO_SERVICE_NAME = 'HeroService'; +export const HERO_SERVICE_NAME = "HeroService"; diff --git a/integration/nestjs-simple-observables/hero.ts b/integration/nestjs-simple-observables/hero.ts index d238e2cb6..7c884baf4 100644 --- a/integration/nestjs-simple-observables/hero.ts +++ b/integration/nestjs-simple-observables/hero.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices'; -import { Observable } from 'rxjs'; +import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices"; +import { Observable } from "rxjs"; -export const protobufPackage = 'hero'; +export const protobufPackage = "hero"; export interface HeroById { id: number; @@ -22,7 +22,7 @@ export interface Villain { name: string; } -export const HERO_PACKAGE_NAME = 'hero'; +export const HERO_PACKAGE_NAME = "hero"; export interface HeroServiceClient { findOneHero(request: HeroById): Observable; @@ -42,17 +42,17 @@ export interface HeroServiceController { export function HeroServiceControllerMethods() { return function (constructor: Function) { - const grpcMethods: string[] = ['findOneHero', 'findOneVillain']; + const grpcMethods: string[] = ["findOneHero", "findOneVillain"]; for (const method of grpcMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } - const grpcStreamMethods: string[] = ['findManyVillain']; + const grpcStreamMethods: string[] = ["findManyVillain"]; for (const method of grpcStreamMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcStreamMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcStreamMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } }; } -export const HERO_SERVICE_NAME = 'HeroService'; +export const HERO_SERVICE_NAME = "HeroService"; diff --git a/integration/nestjs-simple-restparameters/google/protobuf/empty.ts b/integration/nestjs-simple-restparameters/google/protobuf/empty.ts index b50215678..bc4e6ef7b 100644 --- a/integration/nestjs-simple-restparameters/google/protobuf/empty.ts +++ b/integration/nestjs-simple-restparameters/google/protobuf/empty.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A generic empty message that you can re-use to avoid defining duplicated @@ -12,6 +12,7 @@ export const protobufPackage = 'google.protobuf'; * * The JSON representation for `Empty` is empty JSON object `{}`. */ -export interface Empty {} +export interface Empty { +} -export const GOOGLE_PROTOBUF_PACKAGE_NAME = 'google.protobuf'; +export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf"; diff --git a/integration/nestjs-simple-restparameters/hero.ts b/integration/nestjs-simple-restparameters/hero.ts index 475b19809..b7bb522a5 100644 --- a/integration/nestjs-simple-restparameters/hero.ts +++ b/integration/nestjs-simple-restparameters/hero.ts @@ -1,16 +1,16 @@ /* eslint-disable */ -import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices'; -import { Observable } from 'rxjs'; -import { Empty } from './google/protobuf/empty'; +import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices"; +import { Observable } from "rxjs"; +import { Empty } from "./google/protobuf/empty"; -export const protobufPackage = 'hero'; +export const protobufPackage = "hero"; export interface User { id: number; name: string; } -export const HERO_PACKAGE_NAME = 'hero'; +export const HERO_PACKAGE_NAME = "hero"; export interface HeroServiceClient { findCurrentUser(request: Empty, ...rest: any): Observable; @@ -22,17 +22,17 @@ export interface HeroServiceController { export function HeroServiceControllerMethods() { return function (constructor: Function) { - const grpcMethods: string[] = ['findCurrentUser']; + const grpcMethods: string[] = ["findCurrentUser"]; for (const method of grpcMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } const grpcStreamMethods: string[] = []; for (const method of grpcStreamMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcStreamMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcStreamMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } }; } -export const HERO_SERVICE_NAME = 'HeroService'; +export const HERO_SERVICE_NAME = "HeroService"; diff --git a/integration/nestjs-simple/google/protobuf/empty.ts b/integration/nestjs-simple/google/protobuf/empty.ts index b50215678..bc4e6ef7b 100644 --- a/integration/nestjs-simple/google/protobuf/empty.ts +++ b/integration/nestjs-simple/google/protobuf/empty.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A generic empty message that you can re-use to avoid defining duplicated @@ -12,6 +12,7 @@ export const protobufPackage = 'google.protobuf'; * * The JSON representation for `Empty` is empty JSON object `{}`. */ -export interface Empty {} +export interface Empty { +} -export const GOOGLE_PROTOBUF_PACKAGE_NAME = 'google.protobuf'; +export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf"; diff --git a/integration/nestjs-simple/google/protobuf/timestamp.ts b/integration/nestjs-simple/google/protobuf/timestamp.ts index 46f31ae23..c2775e434 100644 --- a/integration/nestjs-simple/google/protobuf/timestamp.ts +++ b/integration/nestjs-simple/google/protobuf/timestamp.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -52,7 +52,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -61,7 +60,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -110,4 +108,4 @@ export interface Timestamp { nanos: number; } -export const GOOGLE_PROTOBUF_PACKAGE_NAME = 'google.protobuf'; +export const GOOGLE_PROTOBUF_PACKAGE_NAME = "google.protobuf"; diff --git a/integration/nestjs-simple/hero.ts b/integration/nestjs-simple/hero.ts index 8bcda1c31..d48eba0ae 100644 --- a/integration/nestjs-simple/hero.ts +++ b/integration/nestjs-simple/hero.ts @@ -1,10 +1,10 @@ /* eslint-disable */ -import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices'; -import { Timestamp } from './google/protobuf/timestamp'; -import { Observable } from 'rxjs'; -import { Empty } from './google/protobuf/empty'; +import { GrpcMethod, GrpcStreamMethod } from "@nestjs/microservices"; +import { Timestamp } from "./google/protobuf/timestamp"; +import { Observable } from "rxjs"; +import { Empty } from "./google/protobuf/empty"; -export const protobufPackage = 'hero'; +export const protobufPackage = "hero"; export interface HeroById { id: number; @@ -25,7 +25,7 @@ export interface Villain { name: string; } -export const HERO_PACKAGE_NAME = 'hero'; +export const HERO_PACKAGE_NAME = "hero"; export interface HeroServiceClient { addOneHero(request: Hero): Observable; @@ -57,17 +57,17 @@ export interface HeroServiceController { export function HeroServiceControllerMethods() { return function (constructor: Function) { - const grpcMethods: string[] = ['addOneHero', 'findOneHero', 'findOneVillain', 'findManyVillainStreamOut']; + const grpcMethods: string[] = ["addOneHero", "findOneHero", "findOneVillain", "findManyVillainStreamOut"]; for (const method of grpcMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } - const grpcStreamMethods: string[] = ['findManyVillain', 'findManyVillainStreamIn']; + const grpcStreamMethods: string[] = ["findManyVillain", "findManyVillainStreamIn"]; for (const method of grpcStreamMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); - GrpcStreamMethod('HeroService', method)(constructor.prototype[method], method, descriptor); + GrpcStreamMethod("HeroService", method)(constructor.prototype[method], method, descriptor); } }; } -export const HERO_SERVICE_NAME = 'HeroService'; +export const HERO_SERVICE_NAME = "HeroService"; diff --git a/integration/nice-grpc/google/protobuf/empty.ts b/integration/nice-grpc/google/protobuf/empty.ts index 3e2434b93..1b2435e42 100644 --- a/integration/nice-grpc/google/protobuf/empty.ts +++ b/integration/nice-grpc/google/protobuf/empty.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A generic empty message that you can re-use to avoid defining duplicated @@ -14,7 +14,8 @@ export const protobufPackage = 'google.protobuf'; * * The JSON representation for `Empty` is empty JSON object `{}`. */ -export interface Empty {} +export interface Empty { +} function createBaseEmpty(): Empty { return {}; @@ -57,12 +58,7 @@ export const Empty = { 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 } +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/integration/nice-grpc/google/protobuf/struct.ts b/integration/nice-grpc/google/protobuf/struct.ts index 3c6bc6cf9..41ef5d717 100644 --- a/integration/nice-grpc/google/protobuf/struct.ts +++ b/integration/nice-grpc/google/protobuf/struct.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the @@ -18,10 +18,10 @@ export enum NullValue { export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: - case 'NULL_VALUE': + case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } @@ -30,10 +30,10 @@ export function nullValueFromJSON(object: any): NullValue { export function nullValueToJSON(object: NullValue): string { switch (object) { case NullValue.NULL_VALUE: - return 'NULL_VALUE'; + return "NULL_VALUE"; case NullValue.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -67,15 +67,25 @@ export interface Struct_FieldsEntry { */ export interface Value { /** Represents a null value. */ - nullValue: NullValue | undefined; + nullValue: + | NullValue + | undefined; /** Represents a double value. */ - numberValue: number | undefined; + numberValue: + | number + | undefined; /** Represents a string value. */ - stringValue: string | undefined; + stringValue: + | string + | undefined; /** Represents a boolean value. */ - boolValue: boolean | undefined; + boolValue: + | boolean + | undefined; /** Represents a structured value. */ - structValue: { [key: string]: any } | undefined; + structValue: + | { [key: string]: any } + | undefined; /** Represents a repeated `Value`. */ listValue: Array | undefined; } @@ -129,9 +139,9 @@ export const 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; - }, {}) + acc[key] = value as any | undefined; + return acc; + }, {}) : {}, }; }, @@ -156,7 +166,7 @@ export const Struct = { } return acc; }, - {} + {}, ); return message; }, @@ -181,12 +191,12 @@ export const Struct = { }; function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Struct_FieldsEntry = { encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -217,10 +227,7 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object?.value) ? object.value : undefined, - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -232,7 +239,7 @@ export const Struct_FieldsEntry = { fromPartial(object: DeepPartial): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -344,18 +351,18 @@ export const Value = { if (value === null) { result.nullValue = NullValue.NULL_VALUE; - } else if (typeof value === 'boolean') { + } else if (typeof value === "boolean") { result.boolValue = value; - } else if (typeof value === 'number') { + } else if (typeof value === "number") { result.numberValue = value; - } else if (typeof value === 'string') { + } else if (typeof value === "string") { result.stringValue = value; } else if (Array.isArray(value)) { result.listValue = value; - } else if (typeof value === 'object') { + } else if (typeof value === "object") { result.structValue = value; - } else if (typeof value !== 'undefined') { - throw new Error('Unsupported any value type: ' + typeof value); + } else if (typeof value !== "undefined") { + throw new Error("Unsupported any value type: " + typeof value); } return result; @@ -410,9 +417,7 @@ export const ListValue = { }, fromJSON(object: any): ListValue { - return { - values: Array.isArray(object?.values) ? [...object.values] : [], - }; + return { values: Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { @@ -446,18 +451,13 @@ export const 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 } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/nice-grpc/google/protobuf/timestamp.ts b/integration/nice-grpc/google/protobuf/timestamp.ts index 7ed68fa81..637f54483 100644 --- a/integration/nice-grpc/google/protobuf/timestamp.ts +++ b/integration/nice-grpc/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,28 +173,31 @@ 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'; + 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 } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/nice-grpc/google/protobuf/wrappers.ts b/integration/nice-grpc/google/protobuf/wrappers.ts index f6b1941f6..21a0c1424 100644 --- a/integration/nice-grpc/google/protobuf/wrappers.ts +++ b/integration/nice-grpc/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial(object: DeepPartial): StringValue { const message = createBaseStringValue(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), - }; + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,31 +552,26 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/nice-grpc/simple.ts b/integration/nice-grpc/simple.ts index a20f3ca76..88901a97f 100644 --- a/integration/nice-grpc/simple.ts +++ b/integration/nice-grpc/simple.ts @@ -1,22 +1,22 @@ /* eslint-disable */ -import { CallContext, CallOptions } from 'nice-grpc-common'; -import { Timestamp } from './google/protobuf/timestamp'; -import { Empty } from './google/protobuf/empty'; +import { CallContext, CallOptions } from "nice-grpc-common"; +import { Timestamp } from "./google/protobuf/timestamp"; +import { Empty } from "./google/protobuf/empty"; import { - StringValue, - Int64Value, - UInt64Value, - Int32Value, - UInt32Value, + BoolValue, BytesValue, - FloatValue, DoubleValue, - BoolValue, -} from './google/protobuf/wrappers'; -import { Struct, Value, ListValue } from './google/protobuf/struct'; -import * as _m0 from 'protobufjs/minimal'; + FloatValue, + Int32Value, + Int64Value, + StringValue, + UInt32Value, + UInt64Value, +} from "./google/protobuf/wrappers"; +import { ListValue, Struct, Value } from "./google/protobuf/struct"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface TestMessage { timestamp: Date | undefined; @@ -53,9 +53,7 @@ export const TestMessage = { }, fromJSON(object: any): TestMessage { - return { - timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, - }; + return { timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined }; }, toJSON(message: TestMessage): unknown { @@ -78,8 +76,8 @@ export const TestMessage = { */ export type TestDefinition = typeof TestDefinition; export const TestDefinition = { - name: 'Test', - fullName: 'simple.Test', + name: "Test", + fullName: "simple.Test", methods: { /** * Unary @@ -87,7 +85,7 @@ export const TestDefinition = { * @deprecated */ unary: { - name: 'Unary', + name: "Unary", requestType: Empty, requestStream: false, responseType: Empty, @@ -95,7 +93,7 @@ export const TestDefinition = { options: {}, }, unaryStringValue: { - name: 'UnaryStringValue', + name: "UnaryStringValue", requestType: StringValue, requestStream: false, responseType: StringValue, @@ -103,7 +101,7 @@ export const TestDefinition = { options: {}, }, unaryInt64Value: { - name: 'UnaryInt64Value', + name: "UnaryInt64Value", requestType: Int64Value, requestStream: false, responseType: Int64Value, @@ -111,7 +109,7 @@ export const TestDefinition = { options: {}, }, unaryUint64Value: { - name: 'UnaryUint64Value', + name: "UnaryUint64Value", requestType: UInt64Value, requestStream: false, responseType: UInt64Value, @@ -119,7 +117,7 @@ export const TestDefinition = { options: {}, }, unaryInt32Value: { - name: 'UnaryInt32Value', + name: "UnaryInt32Value", requestType: Int32Value, requestStream: false, responseType: Int32Value, @@ -127,7 +125,7 @@ export const TestDefinition = { options: {}, }, unaryUInt32Value: { - name: 'UnaryUInt32Value', + name: "UnaryUInt32Value", requestType: UInt32Value, requestStream: false, responseType: UInt32Value, @@ -135,7 +133,7 @@ export const TestDefinition = { options: {}, }, unaryBytesValue: { - name: 'UnaryBytesValue', + name: "UnaryBytesValue", requestType: BytesValue, requestStream: false, responseType: BytesValue, @@ -143,7 +141,7 @@ export const TestDefinition = { options: {}, }, unaryFloatValue: { - name: 'UnaryFloatValue', + name: "UnaryFloatValue", requestType: FloatValue, requestStream: false, responseType: FloatValue, @@ -151,7 +149,7 @@ export const TestDefinition = { options: {}, }, unaryDoubleValue: { - name: 'UnaryDoubleValue', + name: "UnaryDoubleValue", requestType: DoubleValue, requestStream: false, responseType: DoubleValue, @@ -159,7 +157,7 @@ export const TestDefinition = { options: {}, }, unaryBoolValue: { - name: 'UnaryBoolValue', + name: "UnaryBoolValue", requestType: BoolValue, requestStream: false, responseType: BoolValue, @@ -167,7 +165,7 @@ export const TestDefinition = { options: {}, }, unaryTimestamp: { - name: 'UnaryTimestamp', + name: "UnaryTimestamp", requestType: Timestamp, requestStream: false, responseType: Timestamp, @@ -175,7 +173,7 @@ export const TestDefinition = { options: {}, }, struct: { - name: 'Struct', + name: "Struct", requestType: Struct, requestStream: false, responseType: Struct, @@ -183,7 +181,7 @@ export const TestDefinition = { options: {}, }, value: { - name: 'Value', + name: "Value", requestType: Value, requestStream: false, responseType: Value, @@ -191,7 +189,7 @@ export const TestDefinition = { options: {}, }, listValue: { - name: 'ListValue', + name: "ListValue", requestType: ListValue, requestStream: false, responseType: ListValue, @@ -200,7 +198,7 @@ export const TestDefinition = { }, /** Server Streaming */ serverStreaming: { - name: 'ServerStreaming', + name: "ServerStreaming", requestType: TestMessage, requestStream: false, responseType: TestMessage, @@ -208,7 +206,7 @@ export const TestDefinition = { options: {}, }, serverStreamingStringValue: { - name: 'ServerStreamingStringValue', + name: "ServerStreamingStringValue", requestType: StringValue, requestStream: false, responseType: StringValue, @@ -216,7 +214,7 @@ export const TestDefinition = { options: {}, }, serverStreamingStruct: { - name: 'ServerStreamingStruct', + name: "ServerStreamingStruct", requestType: Struct, requestStream: false, responseType: Struct, @@ -225,7 +223,7 @@ export const TestDefinition = { }, /** Client Streaming */ clientStreaming: { - name: 'ClientStreaming', + name: "ClientStreaming", requestType: TestMessage, requestStream: true, responseType: TestMessage, @@ -233,7 +231,7 @@ export const TestDefinition = { options: {}, }, clientStreamingStringValue: { - name: 'ClientStreamingStringValue', + name: "ClientStreamingStringValue", requestType: StringValue, requestStream: true, responseType: StringValue, @@ -242,7 +240,7 @@ export const TestDefinition = { }, /** Bidi Streaming */ bidiStreaming: { - name: 'BidiStreaming', + name: "BidiStreaming", requestType: TestMessage, requestStream: true, responseType: TestMessage, @@ -250,7 +248,7 @@ export const TestDefinition = { options: {}, }, bidiStreamingStringValue: { - name: 'BidiStreamingStringValue', + name: "BidiStreamingStringValue", requestType: StringValue, requestStream: true, responseType: StringValue, @@ -283,33 +281,33 @@ export interface TestServiceImplementation { /** Server Streaming */ serverStreaming( request: TestMessage, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): ServerStreamingMethodResult>; serverStreamingStringValue( request: StringValue, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): ServerStreamingMethodResult>; serverStreamingStruct( request: Struct, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): ServerStreamingMethodResult>; /** Client Streaming */ clientStreaming( request: AsyncIterable, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): Promise>; clientStreamingStringValue( request: AsyncIterable, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): Promise>; /** Bidi Streaming */ bidiStreaming( request: AsyncIterable, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): ServerStreamingMethodResult>; bidiStreamingStringValue( request: AsyncIterable, - context: CallContext & CallContextExt + context: CallContext & CallContextExt, ): ServerStreamingMethodResult>; } @@ -336,43 +334,38 @@ export interface TestClient { /** Server Streaming */ serverStreaming( request: DeepPartial, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): AsyncIterable; serverStreamingStringValue( request: DeepPartial, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): AsyncIterable; serverStreamingStruct(request: DeepPartial, options?: CallOptions & CallOptionsExt): AsyncIterable; /** Client Streaming */ clientStreaming( request: AsyncIterable>, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): Promise; clientStreamingStringValue( request: AsyncIterable>, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): Promise; /** Bidi Streaming */ bidiStreaming( request: AsyncIterable>, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): AsyncIterable; bidiStreamingStringValue( request: AsyncIterable>, - options?: CallOptions & CallOptionsExt + options?: CallOptions & CallOptionsExt, ): AsyncIterable; } 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 } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; function toTimestamp(date: Date): Timestamp { @@ -390,7 +383,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); @@ -401,6 +394,4 @@ function isSet(value: any): boolean { return value !== null && value !== undefined; } -export type ServerStreamingMethodResult = { - [Symbol.asyncIterator](): AsyncIterator; -}; +export type ServerStreamingMethodResult = { [Symbol.asyncIterator](): AsyncIterator }; diff --git a/integration/no-proto-package/no-proto-package.ts b/integration/no-proto-package/no-proto-package.ts index e6ded2193..8f4db6f9b 100644 --- a/integration/no-proto-package/no-proto-package.ts +++ b/integration/no-proto-package/no-proto-package.ts @@ -1,23 +1,24 @@ /* eslint-disable */ -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import * as _m0 from 'protobufjs/minimal'; +import { Observable } from "rxjs"; +import { map } from "rxjs/operators"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface User { name: string; } -export interface Empty {} +export interface Empty { +} function createBaseUser(): User { - return { name: '' }; + return { name: "" }; } export const User = { encode(message: User, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -42,9 +43,7 @@ export const User = { }, fromJSON(object: any): User { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: User): unknown { @@ -55,7 +54,7 @@ export const User = { fromPartial, I>>(object: I): User { const message = createBaseUser(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; @@ -111,7 +110,7 @@ export class UserStateClientImpl implements UserState { } GetUsers(request: Empty): Observable { const data = Empty.encode(request).finish(); - const result = this.rpc.serverStreamingRequest('UserState', 'GetUsers', data); + const result = this.rpc.serverStreamingRequest("UserState", "GetUsers", data); return result.pipe(map((data) => User.decode(new _m0.Reader(data)))); } } @@ -125,19 +124,13 @@ interface Rpc { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/oneof-properties/oneof.ts b/integration/oneof-properties/oneof.ts index 712e979df..a80318c1d 100644 --- a/integration/oneof-properties/oneof.ts +++ b/integration/oneof-properties/oneof.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'oneof'; +export const protobufPackage = "oneof"; export interface PleaseChoose { name: string; @@ -9,13 +9,17 @@ export interface PleaseChoose { * Use this if you want a number. Numbers are great. Who doesn't * like them? */ - aNumber: number | undefined; + aNumber: + | number + | undefined; /** * Use this if you want a string. Strings are also nice. Not as * nice as numbers, but what are you going to do... */ aString: string | undefined; - aMessage: PleaseChoose_Submessage | undefined; + aMessage: + | PleaseChoose_Submessage + | undefined; /** * We also added a bool option! This was added after the 'age' * field, so it has a higher number. @@ -39,16 +43,16 @@ export enum PleaseChoose_StateEnum { export function pleaseChoose_StateEnumFromJSON(object: any): PleaseChoose_StateEnum { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return PleaseChoose_StateEnum.UNKNOWN; case 2: - case 'ON': + case "ON": return PleaseChoose_StateEnum.ON; case 3: - case 'OFF': + case "OFF": return PleaseChoose_StateEnum.OFF; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return PleaseChoose_StateEnum.UNRECOGNIZED; } @@ -57,14 +61,14 @@ export function pleaseChoose_StateEnumFromJSON(object: any): PleaseChoose_StateE export function pleaseChoose_StateEnumToJSON(object: PleaseChoose_StateEnum): string { switch (object) { case PleaseChoose_StateEnum.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case PleaseChoose_StateEnum.ON: - return 'ON'; + return "ON"; case PleaseChoose_StateEnum.OFF: - return 'OFF'; + return "OFF"; case PleaseChoose_StateEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -74,7 +78,7 @@ export interface PleaseChoose_Submessage { function createBasePleaseChoose(): PleaseChoose { return { - name: '', + name: "", aNumber: undefined, aString: undefined, aMessage: undefined, @@ -90,7 +94,7 @@ function createBasePleaseChoose(): PleaseChoose { export const PleaseChoose = { encode(message: PleaseChoose, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.aNumber !== undefined) { @@ -176,7 +180,7 @@ export const PleaseChoose = { fromJSON(object: any): PleaseChoose { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", aNumber: isSet(object.aNumber) ? Number(object.aNumber) : undefined, aString: isSet(object.aString) ? String(object.aString) : undefined, aMessage: isSet(object.aMessage) ? PleaseChoose_Submessage.fromJSON(object.aMessage) : undefined, @@ -211,13 +215,12 @@ export const PleaseChoose = { fromPartial, I>>(object: I): PleaseChoose { const message = createBasePleaseChoose(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.aNumber = object.aNumber ?? undefined; message.aString = object.aString ?? undefined; - message.aMessage = - object.aMessage !== undefined && object.aMessage !== null - ? PleaseChoose_Submessage.fromPartial(object.aMessage) - : undefined; + message.aMessage = (object.aMessage !== undefined && object.aMessage !== null) + ? PleaseChoose_Submessage.fromPartial(object.aMessage) + : undefined; message.aBool = object.aBool ?? undefined; message.bunchaBytes = object.bunchaBytes ?? undefined; message.anEnum = object.anEnum ?? undefined; @@ -230,12 +233,12 @@ export const PleaseChoose = { }; function createBasePleaseChoose_Submessage(): PleaseChoose_Submessage { - return { name: '' }; + return { name: "" }; } export const PleaseChoose_Submessage = { encode(message: PleaseChoose_Submessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -260,9 +263,7 @@ export const PleaseChoose_Submessage = { }, fromJSON(object: any): PleaseChoose_Submessage { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: PleaseChoose_Submessage): unknown { @@ -273,7 +274,7 @@ export const PleaseChoose_Submessage = { fromPartial, I>>(object: I): PleaseChoose_Submessage { const message = createBasePleaseChoose_Submessage(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; @@ -282,16 +283,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -304,31 +313,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/oneof-unions-snake/google/protobuf/struct.ts b/integration/oneof-unions-snake/google/protobuf/struct.ts index dab73bd6a..fdf3803b1 100644 --- a/integration/oneof-unions-snake/google/protobuf/struct.ts +++ b/integration/oneof-unions-snake/google/protobuf/struct.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the @@ -18,10 +18,10 @@ export enum NullValue { export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: - case 'NULL_VALUE': + case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } @@ -30,10 +30,10 @@ export function nullValueFromJSON(object: any): NullValue { export function nullValueToJSON(object: NullValue): string { switch (object) { case NullValue.NULL_VALUE: - return 'NULL_VALUE'; + return "NULL_VALUE"; case NullValue.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -67,12 +67,12 @@ export interface Struct_FieldsEntry { */ export interface Value { kind?: - | { $case: 'null_value'; null_value: NullValue } - | { $case: 'number_value'; number_value: number } - | { $case: 'string_value'; string_value: string } - | { $case: 'bool_value'; bool_value: boolean } - | { $case: 'struct_value'; struct_value: { [key: string]: any } | undefined } - | { $case: 'list_value'; list_value: Array | undefined }; + | { $case: "null_value"; null_value: NullValue } + | { $case: "number_value"; number_value: number } + | { $case: "string_value"; string_value: string } + | { $case: "bool_value"; bool_value: boolean } + | { $case: "struct_value"; struct_value: { [key: string]: any } | undefined } + | { $case: "list_value"; list_value: Array | undefined }; } /** @@ -124,9 +124,9 @@ export const 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; - }, {}) + acc[key] = value as any | undefined; + return acc; + }, {}) : {}, }; }, @@ -151,7 +151,7 @@ export const Struct = { } return acc; }, - {} + {}, ); return message; }, @@ -176,12 +176,12 @@ export const Struct = { }; function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Struct_FieldsEntry = { encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -212,10 +212,7 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object?.value) ? object.value : undefined, - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -227,7 +224,7 @@ export const Struct_FieldsEntry = { fromPartial, I>>(object: I): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -239,22 +236,22 @@ function createBaseValue(): Value { export const Value = { encode(message: Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.kind?.$case === 'null_value') { + if (message.kind?.$case === "null_value") { writer.uint32(8).int32(message.kind.null_value); } - if (message.kind?.$case === 'number_value') { + if (message.kind?.$case === "number_value") { writer.uint32(17).double(message.kind.number_value); } - if (message.kind?.$case === 'string_value') { + if (message.kind?.$case === "string_value") { writer.uint32(26).string(message.kind.string_value); } - if (message.kind?.$case === 'bool_value') { + if (message.kind?.$case === "bool_value") { writer.uint32(32).bool(message.kind.bool_value); } - if (message.kind?.$case === 'struct_value') { + if (message.kind?.$case === "struct_value") { Struct.encode(Struct.wrap(message.kind.struct_value), writer.uint32(42).fork()).ldelim(); } - if (message.kind?.$case === 'list_value') { + if (message.kind?.$case === "list_value") { ListValue.encode(ListValue.wrap(message.kind.list_value), writer.uint32(50).fork()).ldelim(); } return writer; @@ -268,23 +265,23 @@ export const Value = { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.kind = { $case: 'null_value', null_value: reader.int32() as any }; + message.kind = { $case: "null_value", null_value: reader.int32() as any }; break; case 2: - message.kind = { $case: 'number_value', number_value: reader.double() }; + message.kind = { $case: "number_value", number_value: reader.double() }; break; case 3: - message.kind = { $case: 'string_value', string_value: reader.string() }; + message.kind = { $case: "string_value", string_value: reader.string() }; break; case 4: - message.kind = { $case: 'bool_value', bool_value: reader.bool() }; + message.kind = { $case: "bool_value", bool_value: reader.bool() }; break; case 5: - message.kind = { $case: 'struct_value', struct_value: Struct.unwrap(Struct.decode(reader, reader.uint32())) }; + message.kind = { $case: "struct_value", struct_value: Struct.unwrap(Struct.decode(reader, reader.uint32())) }; break; case 6: message.kind = { - $case: 'list_value', + $case: "list_value", list_value: ListValue.unwrap(ListValue.decode(reader, reader.uint32())), }; break; @@ -299,76 +296,70 @@ export const Value = { fromJSON(object: any): Value { return { kind: isSet(object.null_value) - ? { $case: 'null_value', null_value: nullValueFromJSON(object.null_value) } + ? { $case: "null_value", null_value: nullValueFromJSON(object.null_value) } : isSet(object.number_value) - ? { $case: 'number_value', number_value: Number(object.number_value) } + ? { $case: "number_value", number_value: Number(object.number_value) } : isSet(object.string_value) - ? { $case: 'string_value', string_value: String(object.string_value) } + ? { $case: "string_value", string_value: String(object.string_value) } : isSet(object.bool_value) - ? { $case: 'bool_value', bool_value: Boolean(object.bool_value) } + ? { $case: "bool_value", bool_value: Boolean(object.bool_value) } : isSet(object.struct_value) - ? { $case: 'struct_value', struct_value: object.struct_value } + ? { $case: "struct_value", struct_value: object.struct_value } : isSet(object.list_value) - ? { $case: 'list_value', list_value: [...object.list_value] } + ? { $case: "list_value", list_value: [...object.list_value] } : undefined, }; }, toJSON(message: Value): unknown { const obj: any = {}; - message.kind?.$case === 'null_value' && + message.kind?.$case === "null_value" && (obj.null_value = message.kind?.null_value !== undefined ? nullValueToJSON(message.kind?.null_value) : undefined); - message.kind?.$case === 'number_value' && (obj.number_value = message.kind?.number_value); - message.kind?.$case === 'string_value' && (obj.string_value = message.kind?.string_value); - message.kind?.$case === 'bool_value' && (obj.bool_value = message.kind?.bool_value); - message.kind?.$case === 'struct_value' && (obj.struct_value = message.kind?.struct_value); - message.kind?.$case === 'list_value' && (obj.list_value = message.kind?.list_value); + message.kind?.$case === "number_value" && (obj.number_value = message.kind?.number_value); + message.kind?.$case === "string_value" && (obj.string_value = message.kind?.string_value); + message.kind?.$case === "bool_value" && (obj.bool_value = message.kind?.bool_value); + message.kind?.$case === "struct_value" && (obj.struct_value = message.kind?.struct_value); + message.kind?.$case === "list_value" && (obj.list_value = message.kind?.list_value); return obj; }, fromPartial, I>>(object: I): Value { const message = createBaseValue(); if ( - object.kind?.$case === 'null_value' && - object.kind?.null_value !== undefined && - object.kind?.null_value !== null + object.kind?.$case === "null_value" && object.kind?.null_value !== undefined && object.kind?.null_value !== null ) { - message.kind = { $case: 'null_value', null_value: object.kind.null_value }; + message.kind = { $case: "null_value", null_value: object.kind.null_value }; } if ( - object.kind?.$case === 'number_value' && + object.kind?.$case === "number_value" && object.kind?.number_value !== undefined && object.kind?.number_value !== null ) { - message.kind = { $case: 'number_value', number_value: object.kind.number_value }; + message.kind = { $case: "number_value", number_value: object.kind.number_value }; } if ( - object.kind?.$case === 'string_value' && + object.kind?.$case === "string_value" && object.kind?.string_value !== undefined && object.kind?.string_value !== null ) { - message.kind = { $case: 'string_value', string_value: object.kind.string_value }; + message.kind = { $case: "string_value", string_value: object.kind.string_value }; } if ( - object.kind?.$case === 'bool_value' && - object.kind?.bool_value !== undefined && - object.kind?.bool_value !== null + object.kind?.$case === "bool_value" && object.kind?.bool_value !== undefined && object.kind?.bool_value !== null ) { - message.kind = { $case: 'bool_value', bool_value: object.kind.bool_value }; + message.kind = { $case: "bool_value", bool_value: object.kind.bool_value }; } if ( - object.kind?.$case === 'struct_value' && + object.kind?.$case === "struct_value" && object.kind?.struct_value !== undefined && object.kind?.struct_value !== null ) { - message.kind = { $case: 'struct_value', struct_value: object.kind.struct_value }; + message.kind = { $case: "struct_value", struct_value: object.kind.struct_value }; } if ( - object.kind?.$case === 'list_value' && - object.kind?.list_value !== undefined && - object.kind?.list_value !== null + object.kind?.$case === "list_value" && object.kind?.list_value !== undefined && object.kind?.list_value !== null ) { - message.kind = { $case: 'list_value', list_value: object.kind.list_value }; + message.kind = { $case: "list_value", list_value: object.kind.list_value }; } return message; }, @@ -377,36 +368,36 @@ export const Value = { const result = createBaseValue(); if (value === null) { - result.kind = { $case: 'null_value', null_value: NullValue.NULL_VALUE }; - } else if (typeof value === 'boolean') { - result.kind = { $case: 'bool_value', bool_value: value }; - } else if (typeof value === 'number') { - result.kind = { $case: 'number_value', number_value: value }; - } else if (typeof value === 'string') { - result.kind = { $case: 'string_value', string_value: value }; + result.kind = { $case: "null_value", null_value: NullValue.NULL_VALUE }; + } else if (typeof value === "boolean") { + result.kind = { $case: "bool_value", bool_value: value }; + } else if (typeof value === "number") { + result.kind = { $case: "number_value", number_value: value }; + } else if (typeof value === "string") { + result.kind = { $case: "string_value", string_value: value }; } else if (Array.isArray(value)) { - result.kind = { $case: 'list_value', list_value: value }; - } else if (typeof value === 'object') { - result.kind = { $case: 'struct_value', struct_value: value }; - } else if (typeof value !== 'undefined') { - throw new Error('Unsupported any value type: ' + typeof value); + result.kind = { $case: "list_value", list_value: value }; + } else if (typeof value === "object") { + result.kind = { $case: "struct_value", struct_value: 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.kind?.$case === 'null_value') { + if (message.kind?.$case === "null_value") { return null; - } else if (message.kind?.$case === 'number_value') { + } else if (message.kind?.$case === "number_value") { return message.kind?.number_value; - } else if (message.kind?.$case === 'string_value') { + } else if (message.kind?.$case === "string_value") { return message.kind?.string_value; - } else if (message.kind?.$case === 'bool_value') { + } else if (message.kind?.$case === "bool_value") { return message.kind?.bool_value; - } else if (message.kind?.$case === 'struct_value') { + } else if (message.kind?.$case === "struct_value") { return message.kind?.struct_value; - } else if (message.kind?.$case === 'list_value') { + } else if (message.kind?.$case === "list_value") { return message.kind?.list_value; } else { return undefined; @@ -445,9 +436,7 @@ export const ListValue = { }, fromJSON(object: any): ListValue { - return { - values: Array.isArray(object?.values) ? [...object.values] : [], - }; + return { values: Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { @@ -481,25 +470,18 @@ export const 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 { $case: string } - ? { [K in keyof Omit]?: DeepPartial } & { $case: T['$case'] } - : T extends {} - ? { [K in keyof T]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin - ? P +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/oneof-unions-snake/simple.ts b/integration/oneof-unions-snake/simple.ts index 8ee20a9e0..d2a7f12ce 100644 --- a/integration/oneof-unions-snake/simple.ts +++ b/integration/oneof-unions-snake/simple.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; -import { Struct } from './google/protobuf/struct'; +import * as _m0 from "protobufjs/minimal"; +import { Struct } from "./google/protobuf/struct"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; /** * Adding a comment to the syntax will become the first @@ -44,9 +44,7 @@ export const SimpleStruct = { }, fromJSON(object: any): SimpleStruct { - return { - simple_struct: isObject(object.simple_struct) ? object.simple_struct : undefined, - }; + return { simple_struct: isObject(object.simple_struct) ? object.simple_struct : undefined }; }, toJSON(message: SimpleStruct): unknown { @@ -64,23 +62,16 @@ export const SimpleStruct = { 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 { $case: string } - ? { [K in keyof Omit]?: DeepPartial } & { $case: T['$case'] } - : T extends {} - ? { [K in keyof T]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin - ? P +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } diff --git a/integration/oneof-unions/google/protobuf/struct.ts b/integration/oneof-unions/google/protobuf/struct.ts index f44e765d4..4a5c792f7 100644 --- a/integration/oneof-unions/google/protobuf/struct.ts +++ b/integration/oneof-unions/google/protobuf/struct.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the @@ -18,10 +18,10 @@ export enum NullValue { export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: - case 'NULL_VALUE': + case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } @@ -30,10 +30,10 @@ export function nullValueFromJSON(object: any): NullValue { export function nullValueToJSON(object: NullValue): string { switch (object) { case NullValue.NULL_VALUE: - return 'NULL_VALUE'; + return "NULL_VALUE"; case NullValue.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -67,12 +67,12 @@ export interface Struct_FieldsEntry { */ export interface Value { kind?: - | { $case: 'nullValue'; nullValue: NullValue } - | { $case: 'numberValue'; numberValue: number } - | { $case: 'stringValue'; stringValue: string } - | { $case: 'boolValue'; boolValue: boolean } - | { $case: 'structValue'; structValue: { [key: string]: any } | undefined } - | { $case: 'listValue'; listValue: Array | undefined }; + | { $case: "nullValue"; nullValue: NullValue } + | { $case: "numberValue"; numberValue: number } + | { $case: "stringValue"; stringValue: string } + | { $case: "boolValue"; boolValue: boolean } + | { $case: "structValue"; structValue: { [key: string]: any } | undefined } + | { $case: "listValue"; listValue: Array | undefined }; } /** @@ -124,9 +124,9 @@ export const 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; - }, {}) + acc[key] = value as any | undefined; + return acc; + }, {}) : {}, }; }, @@ -151,7 +151,7 @@ export const Struct = { } return acc; }, - {} + {}, ); return message; }, @@ -176,12 +176,12 @@ export const Struct = { }; function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Struct_FieldsEntry = { encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -212,10 +212,7 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object?.value) ? object.value : undefined, - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -227,7 +224,7 @@ export const Struct_FieldsEntry = { fromPartial, I>>(object: I): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -239,22 +236,22 @@ function createBaseValue(): Value { export const Value = { encode(message: Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.kind?.$case === 'nullValue') { + if (message.kind?.$case === "nullValue") { writer.uint32(8).int32(message.kind.nullValue); } - if (message.kind?.$case === 'numberValue') { + if (message.kind?.$case === "numberValue") { writer.uint32(17).double(message.kind.numberValue); } - if (message.kind?.$case === 'stringValue') { + if (message.kind?.$case === "stringValue") { writer.uint32(26).string(message.kind.stringValue); } - if (message.kind?.$case === 'boolValue') { + if (message.kind?.$case === "boolValue") { writer.uint32(32).bool(message.kind.boolValue); } - if (message.kind?.$case === 'structValue') { + if (message.kind?.$case === "structValue") { Struct.encode(Struct.wrap(message.kind.structValue), writer.uint32(42).fork()).ldelim(); } - if (message.kind?.$case === 'listValue') { + if (message.kind?.$case === "listValue") { ListValue.encode(ListValue.wrap(message.kind.listValue), writer.uint32(50).fork()).ldelim(); } return writer; @@ -268,22 +265,22 @@ export const Value = { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.kind = { $case: 'nullValue', nullValue: reader.int32() as any }; + message.kind = { $case: "nullValue", nullValue: reader.int32() as any }; break; case 2: - message.kind = { $case: 'numberValue', numberValue: reader.double() }; + message.kind = { $case: "numberValue", numberValue: reader.double() }; break; case 3: - message.kind = { $case: 'stringValue', stringValue: reader.string() }; + message.kind = { $case: "stringValue", stringValue: reader.string() }; break; case 4: - message.kind = { $case: 'boolValue', boolValue: reader.bool() }; + message.kind = { $case: "boolValue", boolValue: reader.bool() }; break; case 5: - message.kind = { $case: 'structValue', structValue: Struct.unwrap(Struct.decode(reader, reader.uint32())) }; + message.kind = { $case: "structValue", structValue: Struct.unwrap(Struct.decode(reader, reader.uint32())) }; break; case 6: - message.kind = { $case: 'listValue', listValue: ListValue.unwrap(ListValue.decode(reader, reader.uint32())) }; + message.kind = { $case: "listValue", listValue: ListValue.unwrap(ListValue.decode(reader, reader.uint32())) }; break; default: reader.skipType(tag & 7); @@ -296,64 +293,64 @@ export const Value = { fromJSON(object: any): Value { return { kind: isSet(object.nullValue) - ? { $case: 'nullValue', nullValue: nullValueFromJSON(object.nullValue) } + ? { $case: "nullValue", nullValue: nullValueFromJSON(object.nullValue) } : isSet(object.numberValue) - ? { $case: 'numberValue', numberValue: Number(object.numberValue) } + ? { $case: "numberValue", numberValue: Number(object.numberValue) } : isSet(object.stringValue) - ? { $case: 'stringValue', stringValue: String(object.stringValue) } + ? { $case: "stringValue", stringValue: String(object.stringValue) } : isSet(object.boolValue) - ? { $case: 'boolValue', boolValue: Boolean(object.boolValue) } + ? { $case: "boolValue", boolValue: Boolean(object.boolValue) } : isSet(object.structValue) - ? { $case: 'structValue', structValue: object.structValue } + ? { $case: "structValue", structValue: object.structValue } : isSet(object.listValue) - ? { $case: 'listValue', listValue: [...object.listValue] } + ? { $case: "listValue", listValue: [...object.listValue] } : undefined, }; }, toJSON(message: Value): unknown { const obj: any = {}; - message.kind?.$case === 'nullValue' && + message.kind?.$case === "nullValue" && (obj.nullValue = message.kind?.nullValue !== undefined ? nullValueToJSON(message.kind?.nullValue) : undefined); - message.kind?.$case === 'numberValue' && (obj.numberValue = message.kind?.numberValue); - message.kind?.$case === 'stringValue' && (obj.stringValue = message.kind?.stringValue); - message.kind?.$case === 'boolValue' && (obj.boolValue = message.kind?.boolValue); - message.kind?.$case === 'structValue' && (obj.structValue = message.kind?.structValue); - message.kind?.$case === 'listValue' && (obj.listValue = message.kind?.listValue); + message.kind?.$case === "numberValue" && (obj.numberValue = message.kind?.numberValue); + message.kind?.$case === "stringValue" && (obj.stringValue = message.kind?.stringValue); + message.kind?.$case === "boolValue" && (obj.boolValue = message.kind?.boolValue); + message.kind?.$case === "structValue" && (obj.structValue = message.kind?.structValue); + message.kind?.$case === "listValue" && (obj.listValue = message.kind?.listValue); return obj; }, fromPartial, I>>(object: I): Value { const message = createBaseValue(); - if (object.kind?.$case === 'nullValue' && object.kind?.nullValue !== undefined && object.kind?.nullValue !== null) { - message.kind = { $case: 'nullValue', nullValue: object.kind.nullValue }; + if (object.kind?.$case === "nullValue" && object.kind?.nullValue !== undefined && object.kind?.nullValue !== null) { + message.kind = { $case: "nullValue", nullValue: object.kind.nullValue }; } if ( - object.kind?.$case === 'numberValue' && + object.kind?.$case === "numberValue" && object.kind?.numberValue !== undefined && object.kind?.numberValue !== null ) { - message.kind = { $case: 'numberValue', numberValue: object.kind.numberValue }; + message.kind = { $case: "numberValue", numberValue: object.kind.numberValue }; } if ( - object.kind?.$case === 'stringValue' && + object.kind?.$case === "stringValue" && object.kind?.stringValue !== undefined && object.kind?.stringValue !== null ) { - message.kind = { $case: 'stringValue', stringValue: object.kind.stringValue }; + message.kind = { $case: "stringValue", stringValue: object.kind.stringValue }; } - if (object.kind?.$case === 'boolValue' && object.kind?.boolValue !== undefined && object.kind?.boolValue !== null) { - message.kind = { $case: 'boolValue', boolValue: object.kind.boolValue }; + if (object.kind?.$case === "boolValue" && object.kind?.boolValue !== undefined && object.kind?.boolValue !== null) { + message.kind = { $case: "boolValue", boolValue: object.kind.boolValue }; } if ( - object.kind?.$case === 'structValue' && + object.kind?.$case === "structValue" && object.kind?.structValue !== undefined && object.kind?.structValue !== null ) { - message.kind = { $case: 'structValue', structValue: object.kind.structValue }; + message.kind = { $case: "structValue", structValue: object.kind.structValue }; } - if (object.kind?.$case === 'listValue' && object.kind?.listValue !== undefined && object.kind?.listValue !== null) { - message.kind = { $case: 'listValue', listValue: object.kind.listValue }; + if (object.kind?.$case === "listValue" && object.kind?.listValue !== undefined && object.kind?.listValue !== null) { + message.kind = { $case: "listValue", listValue: object.kind.listValue }; } return message; }, @@ -362,36 +359,36 @@ export const Value = { const result = createBaseValue(); if (value === null) { - result.kind = { $case: 'nullValue', nullValue: NullValue.NULL_VALUE }; - } else if (typeof value === 'boolean') { - result.kind = { $case: 'boolValue', boolValue: value }; - } else if (typeof value === 'number') { - result.kind = { $case: 'numberValue', numberValue: value }; - } else if (typeof value === 'string') { - result.kind = { $case: 'stringValue', stringValue: value }; + result.kind = { $case: "nullValue", nullValue: NullValue.NULL_VALUE }; + } else if (typeof value === "boolean") { + result.kind = { $case: "boolValue", boolValue: value }; + } else if (typeof value === "number") { + result.kind = { $case: "numberValue", numberValue: value }; + } else if (typeof value === "string") { + result.kind = { $case: "stringValue", stringValue: value }; } else if (Array.isArray(value)) { - result.kind = { $case: 'listValue', listValue: value }; - } else if (typeof value === 'object') { - result.kind = { $case: 'structValue', structValue: value }; - } else if (typeof value !== 'undefined') { - throw new Error('Unsupported any value type: ' + typeof value); + result.kind = { $case: "listValue", listValue: value }; + } else if (typeof value === "object") { + result.kind = { $case: "structValue", 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.kind?.$case === 'nullValue') { + if (message.kind?.$case === "nullValue") { return null; - } else if (message.kind?.$case === 'numberValue') { + } else if (message.kind?.$case === "numberValue") { return message.kind?.numberValue; - } else if (message.kind?.$case === 'stringValue') { + } else if (message.kind?.$case === "stringValue") { return message.kind?.stringValue; - } else if (message.kind?.$case === 'boolValue') { + } else if (message.kind?.$case === "boolValue") { return message.kind?.boolValue; - } else if (message.kind?.$case === 'structValue') { + } else if (message.kind?.$case === "structValue") { return message.kind?.structValue; - } else if (message.kind?.$case === 'listValue') { + } else if (message.kind?.$case === "listValue") { return message.kind?.listValue; } else { return undefined; @@ -430,9 +427,7 @@ export const ListValue = { }, fromJSON(object: any): ListValue { - return { - values: Array.isArray(object?.values) ? [...object.values] : [], - }; + return { values: Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { @@ -466,25 +461,18 @@ export const 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 { $case: string } - ? { [K in keyof Omit]?: DeepPartial } & { $case: T['$case'] } - : T extends {} - ? { [K in keyof T]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin - ? P +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/oneof-unions/oneof.ts b/integration/oneof-unions/oneof.ts index 1e0840843..e89ecca74 100644 --- a/integration/oneof-unions/oneof.ts +++ b/integration/oneof-unions/oneof.ts @@ -1,23 +1,23 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; -import { Value } from './google/protobuf/struct'; +import * as _m0 from "protobufjs/minimal"; +import { Value } from "./google/protobuf/struct"; -export const protobufPackage = 'oneof'; +export const protobufPackage = "oneof"; export interface PleaseChoose { name: string; choice?: - | { $case: 'aNumber'; aNumber: number } - | { $case: 'aString'; aString: string } - | { $case: 'aMessage'; aMessage: PleaseChoose_Submessage } - | { $case: 'aBool'; aBool: boolean } - | { $case: 'bunchaBytes'; bunchaBytes: Uint8Array } - | { $case: 'anEnum'; anEnum: PleaseChoose_StateEnum }; + | { $case: "aNumber"; aNumber: number } + | { $case: "aString"; aString: string } + | { $case: "aMessage"; aMessage: PleaseChoose_Submessage } + | { $case: "aBool"; aBool: boolean } + | { $case: "bunchaBytes"; bunchaBytes: Uint8Array } + | { $case: "anEnum"; anEnum: PleaseChoose_StateEnum }; age: number; - eitherOr?: - | { $case: 'either'; either: string } - | { $case: 'or'; or: string } - | { $case: 'thirdOption'; thirdOption: string }; + eitherOr?: { $case: "either"; either: string } | { $case: "or"; or: string } | { + $case: "thirdOption"; + thirdOption: string; + }; signature: Uint8Array; value: any | undefined; } @@ -32,16 +32,16 @@ export enum PleaseChoose_StateEnum { export function pleaseChoose_StateEnumFromJSON(object: any): PleaseChoose_StateEnum { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return PleaseChoose_StateEnum.UNKNOWN; case 2: - case 'ON': + case "ON": return PleaseChoose_StateEnum.ON; case 3: - case 'OFF': + case "OFF": return PleaseChoose_StateEnum.OFF; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return PleaseChoose_StateEnum.UNRECOGNIZED; } @@ -50,14 +50,14 @@ export function pleaseChoose_StateEnumFromJSON(object: any): PleaseChoose_StateE export function pleaseChoose_StateEnumToJSON(object: PleaseChoose_StateEnum): string { switch (object) { case PleaseChoose_StateEnum.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case PleaseChoose_StateEnum.ON: - return 'ON'; + return "ON"; case PleaseChoose_StateEnum.OFF: - return 'OFF'; + return "OFF"; case PleaseChoose_StateEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -72,42 +72,42 @@ export interface SimpleButOptional { } function createBasePleaseChoose(): PleaseChoose { - return { name: '', choice: undefined, age: 0, eitherOr: undefined, signature: new Uint8Array(), value: undefined }; + return { name: "", choice: undefined, age: 0, eitherOr: undefined, signature: new Uint8Array(), value: undefined }; } export const PleaseChoose = { encode(message: PleaseChoose, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } - if (message.choice?.$case === 'aNumber') { + if (message.choice?.$case === "aNumber") { writer.uint32(17).double(message.choice.aNumber); } - if (message.choice?.$case === 'aString') { + if (message.choice?.$case === "aString") { writer.uint32(26).string(message.choice.aString); } - if (message.choice?.$case === 'aMessage') { + if (message.choice?.$case === "aMessage") { PleaseChoose_Submessage.encode(message.choice.aMessage, writer.uint32(34).fork()).ldelim(); } - if (message.choice?.$case === 'aBool') { + if (message.choice?.$case === "aBool") { writer.uint32(48).bool(message.choice.aBool); } - if (message.choice?.$case === 'bunchaBytes') { + if (message.choice?.$case === "bunchaBytes") { writer.uint32(82).bytes(message.choice.bunchaBytes); } - if (message.choice?.$case === 'anEnum') { + if (message.choice?.$case === "anEnum") { writer.uint32(88).int32(message.choice.anEnum); } if (message.age !== 0) { writer.uint32(40).uint32(message.age); } - if (message.eitherOr?.$case === 'either') { + if (message.eitherOr?.$case === "either") { writer.uint32(58).string(message.eitherOr.either); } - if (message.eitherOr?.$case === 'or') { + if (message.eitherOr?.$case === "or") { writer.uint32(66).string(message.eitherOr.or); } - if (message.eitherOr?.$case === 'thirdOption') { + if (message.eitherOr?.$case === "thirdOption") { writer.uint32(74).string(message.eitherOr.thirdOption); } if (message.signature.length !== 0) { @@ -130,34 +130,34 @@ export const PleaseChoose = { message.name = reader.string(); break; case 2: - message.choice = { $case: 'aNumber', aNumber: reader.double() }; + message.choice = { $case: "aNumber", aNumber: reader.double() }; break; case 3: - message.choice = { $case: 'aString', aString: reader.string() }; + message.choice = { $case: "aString", aString: reader.string() }; break; case 4: - message.choice = { $case: 'aMessage', aMessage: PleaseChoose_Submessage.decode(reader, reader.uint32()) }; + message.choice = { $case: "aMessage", aMessage: PleaseChoose_Submessage.decode(reader, reader.uint32()) }; break; case 6: - message.choice = { $case: 'aBool', aBool: reader.bool() }; + message.choice = { $case: "aBool", aBool: reader.bool() }; break; case 10: - message.choice = { $case: 'bunchaBytes', bunchaBytes: reader.bytes() }; + message.choice = { $case: "bunchaBytes", bunchaBytes: reader.bytes() }; break; case 11: - message.choice = { $case: 'anEnum', anEnum: reader.int32() as any }; + message.choice = { $case: "anEnum", anEnum: reader.int32() as any }; break; case 5: message.age = reader.uint32(); break; case 7: - message.eitherOr = { $case: 'either', either: reader.string() }; + message.eitherOr = { $case: "either", either: reader.string() }; break; case 8: - message.eitherOr = { $case: 'or', or: reader.string() }; + message.eitherOr = { $case: "or", or: reader.string() }; break; case 9: - message.eitherOr = { $case: 'thirdOption', thirdOption: reader.string() }; + message.eitherOr = { $case: "thirdOption", thirdOption: reader.string() }; break; case 12: message.signature = reader.bytes(); @@ -175,27 +175,27 @@ export const PleaseChoose = { fromJSON(object: any): PleaseChoose { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", choice: isSet(object.aNumber) - ? { $case: 'aNumber', aNumber: Number(object.aNumber) } + ? { $case: "aNumber", aNumber: Number(object.aNumber) } : isSet(object.aString) - ? { $case: 'aString', aString: String(object.aString) } + ? { $case: "aString", aString: String(object.aString) } : isSet(object.aMessage) - ? { $case: 'aMessage', aMessage: PleaseChoose_Submessage.fromJSON(object.aMessage) } + ? { $case: "aMessage", aMessage: PleaseChoose_Submessage.fromJSON(object.aMessage) } : isSet(object.aBool) - ? { $case: 'aBool', aBool: Boolean(object.aBool) } + ? { $case: "aBool", aBool: Boolean(object.aBool) } : isSet(object.bunchaBytes) - ? { $case: 'bunchaBytes', bunchaBytes: bytesFromBase64(object.bunchaBytes) } + ? { $case: "bunchaBytes", bunchaBytes: bytesFromBase64(object.bunchaBytes) } : isSet(object.anEnum) - ? { $case: 'anEnum', anEnum: pleaseChoose_StateEnumFromJSON(object.anEnum) } + ? { $case: "anEnum", anEnum: pleaseChoose_StateEnumFromJSON(object.anEnum) } : undefined, age: isSet(object.age) ? Number(object.age) : 0, eitherOr: isSet(object.either) - ? { $case: 'either', either: String(object.either) } + ? { $case: "either", either: String(object.either) } : isSet(object.or) - ? { $case: 'or', or: String(object.or) } + ? { $case: "or", or: String(object.or) } : isSet(object.thirdOption) - ? { $case: 'thirdOption', thirdOption: String(object.thirdOption) } + ? { $case: "thirdOption", thirdOption: String(object.thirdOption) } : undefined, signature: isSet(object.signature) ? bytesFromBase64(object.signature) : new Uint8Array(), value: isSet(object?.value) ? object.value : undefined, @@ -205,21 +205,21 @@ export const PleaseChoose = { toJSON(message: PleaseChoose): unknown { const obj: any = {}; message.name !== undefined && (obj.name = message.name); - message.choice?.$case === 'aNumber' && (obj.aNumber = message.choice?.aNumber); - message.choice?.$case === 'aString' && (obj.aString = message.choice?.aString); - message.choice?.$case === 'aMessage' && + message.choice?.$case === "aNumber" && (obj.aNumber = message.choice?.aNumber); + message.choice?.$case === "aString" && (obj.aString = message.choice?.aString); + message.choice?.$case === "aMessage" && (obj.aMessage = message.choice?.aMessage ? PleaseChoose_Submessage.toJSON(message.choice?.aMessage) : undefined); - message.choice?.$case === 'aBool' && (obj.aBool = message.choice?.aBool); - message.choice?.$case === 'bunchaBytes' && - (obj.bunchaBytes = - message.choice?.bunchaBytes !== undefined ? base64FromBytes(message.choice?.bunchaBytes) : undefined); - message.choice?.$case === 'anEnum' && - (obj.anEnum = - message.choice?.anEnum !== undefined ? pleaseChoose_StateEnumToJSON(message.choice?.anEnum) : undefined); + message.choice?.$case === "aBool" && (obj.aBool = message.choice?.aBool); + message.choice?.$case === "bunchaBytes" && (obj.bunchaBytes = message.choice?.bunchaBytes !== undefined + ? base64FromBytes(message.choice?.bunchaBytes) + : undefined); + message.choice?.$case === "anEnum" && (obj.anEnum = message.choice?.anEnum !== undefined + ? pleaseChoose_StateEnumToJSON(message.choice?.anEnum) + : undefined); message.age !== undefined && (obj.age = Math.round(message.age)); - message.eitherOr?.$case === 'either' && (obj.either = message.eitherOr?.either); - message.eitherOr?.$case === 'or' && (obj.or = message.eitherOr?.or); - message.eitherOr?.$case === 'thirdOption' && (obj.thirdOption = message.eitherOr?.thirdOption); + message.eitherOr?.$case === "either" && (obj.either = message.eitherOr?.either); + message.eitherOr?.$case === "or" && (obj.or = message.eitherOr?.or); + message.eitherOr?.$case === "thirdOption" && (obj.thirdOption = message.eitherOr?.thirdOption); message.signature !== undefined && (obj.signature = base64FromBytes(message.signature !== undefined ? message.signature : new Uint8Array())); message.value !== undefined && (obj.value = message.value); @@ -228,50 +228,46 @@ export const PleaseChoose = { fromPartial, I>>(object: I): PleaseChoose { const message = createBasePleaseChoose(); - message.name = object.name ?? ''; - if (object.choice?.$case === 'aNumber' && object.choice?.aNumber !== undefined && object.choice?.aNumber !== null) { - message.choice = { $case: 'aNumber', aNumber: object.choice.aNumber }; + message.name = object.name ?? ""; + if (object.choice?.$case === "aNumber" && object.choice?.aNumber !== undefined && object.choice?.aNumber !== null) { + message.choice = { $case: "aNumber", aNumber: object.choice.aNumber }; } - if (object.choice?.$case === 'aString' && object.choice?.aString !== undefined && object.choice?.aString !== null) { - message.choice = { $case: 'aString', aString: object.choice.aString }; + if (object.choice?.$case === "aString" && object.choice?.aString !== undefined && object.choice?.aString !== null) { + message.choice = { $case: "aString", aString: object.choice.aString }; } if ( - object.choice?.$case === 'aMessage' && - object.choice?.aMessage !== undefined && - object.choice?.aMessage !== null + object.choice?.$case === "aMessage" && object.choice?.aMessage !== undefined && object.choice?.aMessage !== null ) { - message.choice = { $case: 'aMessage', aMessage: PleaseChoose_Submessage.fromPartial(object.choice.aMessage) }; + message.choice = { $case: "aMessage", aMessage: PleaseChoose_Submessage.fromPartial(object.choice.aMessage) }; } - if (object.choice?.$case === 'aBool' && object.choice?.aBool !== undefined && object.choice?.aBool !== null) { - message.choice = { $case: 'aBool', aBool: object.choice.aBool }; + if (object.choice?.$case === "aBool" && object.choice?.aBool !== undefined && object.choice?.aBool !== null) { + message.choice = { $case: "aBool", aBool: object.choice.aBool }; } if ( - object.choice?.$case === 'bunchaBytes' && + object.choice?.$case === "bunchaBytes" && object.choice?.bunchaBytes !== undefined && object.choice?.bunchaBytes !== null ) { - message.choice = { $case: 'bunchaBytes', bunchaBytes: object.choice.bunchaBytes }; + message.choice = { $case: "bunchaBytes", bunchaBytes: object.choice.bunchaBytes }; } - if (object.choice?.$case === 'anEnum' && object.choice?.anEnum !== undefined && object.choice?.anEnum !== null) { - message.choice = { $case: 'anEnum', anEnum: object.choice.anEnum }; + if (object.choice?.$case === "anEnum" && object.choice?.anEnum !== undefined && object.choice?.anEnum !== null) { + message.choice = { $case: "anEnum", anEnum: object.choice.anEnum }; } message.age = object.age ?? 0; if ( - object.eitherOr?.$case === 'either' && - object.eitherOr?.either !== undefined && - object.eitherOr?.either !== null + object.eitherOr?.$case === "either" && object.eitherOr?.either !== undefined && object.eitherOr?.either !== null ) { - message.eitherOr = { $case: 'either', either: object.eitherOr.either }; + message.eitherOr = { $case: "either", either: object.eitherOr.either }; } - if (object.eitherOr?.$case === 'or' && object.eitherOr?.or !== undefined && object.eitherOr?.or !== null) { - message.eitherOr = { $case: 'or', or: object.eitherOr.or }; + if (object.eitherOr?.$case === "or" && object.eitherOr?.or !== undefined && object.eitherOr?.or !== null) { + message.eitherOr = { $case: "or", or: object.eitherOr.or }; } if ( - object.eitherOr?.$case === 'thirdOption' && + object.eitherOr?.$case === "thirdOption" && object.eitherOr?.thirdOption !== undefined && object.eitherOr?.thirdOption !== null ) { - message.eitherOr = { $case: 'thirdOption', thirdOption: object.eitherOr.thirdOption }; + message.eitherOr = { $case: "thirdOption", thirdOption: object.eitherOr.thirdOption }; } message.signature = object.signature ?? new Uint8Array(); message.value = object.value ?? undefined; @@ -280,12 +276,12 @@ export const PleaseChoose = { }; function createBasePleaseChoose_Submessage(): PleaseChoose_Submessage { - return { name: '' }; + return { name: "" }; } export const PleaseChoose_Submessage = { encode(message: PleaseChoose_Submessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -310,9 +306,7 @@ export const PleaseChoose_Submessage = { }, fromJSON(object: any): PleaseChoose_Submessage { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: PleaseChoose_Submessage): unknown { @@ -323,7 +317,7 @@ export const PleaseChoose_Submessage = { fromPartial, I>>(object: I): PleaseChoose_Submessage { const message = createBasePleaseChoose_Submessage(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; @@ -390,16 +384,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -412,33 +414,26 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 { $case: string } - ? { [K in keyof Omit]?: DeepPartial } & { $case: T['$case'] } - : T extends {} - ? { [K in keyof T]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends { $case: string } ? { [K in keyof Omit]?: DeepPartial } & { $case: T["$case"] } + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; type KeysOfUnion = T extends T ? keyof T : never; -export type Exact = P extends Builtin - ? P +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/only-types-grpc-metadata/only-types-grpc-metadata.ts b/integration/only-types-grpc-metadata/only-types-grpc-metadata.ts index 0a34c406e..1848fde18 100644 --- a/integration/only-types-grpc-metadata/only-types-grpc-metadata.ts +++ b/integration/only-types-grpc-metadata/only-types-grpc-metadata.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import { Metadata } from '@grpc/grpc-js'; +import { Metadata } from "@grpc/grpc-js"; -export const protobufPackage = 'basic'; +export const protobufPackage = "basic"; export interface GetBasicRequest { name: string; diff --git a/integration/only-types/google/protobuf/any.ts b/integration/only-types/google/protobuf/any.ts index ade2721aa..a2064bff7 100644 --- a/integration/only-types/google/protobuf/any.ts +++ b/integration/only-types/google/protobuf/any.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `Any` contains an arbitrary serialized protocol buffer message along with a @@ -56,7 +56,6 @@ export const protobufPackage = 'google.protobuf'; * in the type URL, for example "foo.bar.com/x/y.z" will yield type * name "y.z". * - * * JSON * ==== * The JSON representation of an `Any` value uses the regular diff --git a/integration/only-types/google/protobuf/timestamp.ts b/integration/only-types/google/protobuf/timestamp.ts index c88251a53..254ed2939 100644 --- a/integration/only-types/google/protobuf/timestamp.ts +++ b/integration/only-types/google/protobuf/timestamp.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -52,7 +52,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -61,7 +60,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() diff --git a/integration/only-types/reservation.ts b/integration/only-types/reservation.ts index 9be27342b..452b9d354 100644 --- a/integration/only-types/reservation.ts +++ b/integration/only-types/reservation.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import type { Any } from './google/protobuf/any'; +import type { Any } from "./google/protobuf/any"; -export const protobufPackage = 'event'; +export const protobufPackage = "event"; export interface Registration { eventName: string; diff --git a/integration/options/google/protobuf/descriptor.ts b/integration/options/google/protobuf/descriptor.ts index cb12e8ba3..165656a02 100644 --- a/integration/options/google/protobuf/descriptor.ts +++ b/integration/options/google/protobuf/descriptor.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { FileDescriptorProto as FileDescriptorProto1 } from 'ts-proto-descriptors'; -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import { FileDescriptorProto as FileDescriptorProto1 } from "ts-proto-descriptors"; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * The protocol compiler can output a FileDescriptorSet containing the .proto @@ -33,14 +33,18 @@ export interface FileDescriptorProto { enumType: EnumDescriptorProto[]; service: ServiceDescriptorProto[]; extension: FieldDescriptorProto[]; - options: FileOptions | undefined; + options: + | FileOptions + | undefined; /** * This field contains optional information about the original source code. * You may safely remove this entire field without harming runtime * functionality of the descriptors -- the information is needed only by * development tools. */ - sourceCodeInfo: SourceCodeInfo | undefined; + sourceCodeInfo: + | SourceCodeInfo + | undefined; /** * The syntax of the proto file. * The supported values are "proto2" and "proto3". @@ -134,7 +138,9 @@ export interface FieldDescriptorProto { * it to camelCase. */ jsonName: string; - options: FieldOptions | undefined; + options: + | FieldOptions + | undefined; /** * If true, this is a proto3 "optional". When a proto3 field is optional, it * tracks presence regardless of field type. @@ -223,7 +229,9 @@ export interface OneofDescriptorProto { export interface EnumDescriptorProto { name: string; value: EnumValueDescriptorProto[]; - options: EnumOptions | undefined; + options: + | EnumOptions + | undefined; /** * Range of reserved numeric values. Reserved numeric values may not be used * by enum values in the same enum declaration. Reserved ranges may not @@ -275,7 +283,9 @@ export interface MethodDescriptorProto { */ inputType: string; outputType: string; - options: MethodOptions | undefined; + options: + | MethodOptions + | undefined; /** Identifies if client streams multiple client messages */ clientStreaming: boolean; /** Identifies if server streams multiple server messages */ @@ -525,7 +535,6 @@ export interface FieldOptions { * call from multiple threads concurrently, while non-const methods continue * to require exclusive access. * - * * Note that implementations may choose not to check required fields within * a lazy sub-message. That is, calling IsInitialized() on the outer message * may return true even if the inner message has missing required fields. @@ -885,8 +894,8 @@ export const FileDescriptorSet = { function createBaseFileDescriptorProto(): FileDescriptorProto { return { - name: '', - package: '', + name: "", + package: "", dependency: [], publicDependency: [], weakDependency: [], @@ -896,16 +905,16 @@ function createBaseFileDescriptorProto(): FileDescriptorProto { extension: [], options: undefined, sourceCodeInfo: undefined, - syntax: '', + syntax: "", }; } export const FileDescriptorProto = { encode(message: FileDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } - if (message.package !== '') { + if (message.package !== "") { writer.uint32(18).string(message.package); } for (const v of message.dependency) { @@ -939,7 +948,7 @@ export const FileDescriptorProto = { if (message.sourceCodeInfo !== undefined) { SourceCodeInfo.encode(message.sourceCodeInfo, writer.uint32(74).fork()).ldelim(); } - if (message.syntax !== '') { + if (message.syntax !== "") { writer.uint32(98).string(message.syntax); } return writer; @@ -1013,7 +1022,7 @@ export const FileDescriptorProto = { function createBaseDescriptorProto(): DescriptorProto { return { - name: '', + name: "", field: [], extension: [], nestedType: [], @@ -1028,7 +1037,7 @@ function createBaseDescriptorProto(): DescriptorProto { export const DescriptorProto = { encode(message: DescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } for (const v of message.field) { @@ -1220,15 +1229,15 @@ export const ExtensionRangeOptions = { function createBaseFieldDescriptorProto(): FieldDescriptorProto { return { - name: '', + name: "", number: 0, label: 1, type: 1, - typeName: '', - extendee: '', - defaultValue: '', + typeName: "", + extendee: "", + defaultValue: "", oneofIndex: 0, - jsonName: '', + jsonName: "", options: undefined, proto3Optional: false, }; @@ -1236,7 +1245,7 @@ function createBaseFieldDescriptorProto(): FieldDescriptorProto { export const FieldDescriptorProto = { encode(message: FieldDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.number !== 0) { @@ -1248,19 +1257,19 @@ export const FieldDescriptorProto = { if (message.type !== 1) { writer.uint32(40).int32(message.type); } - if (message.typeName !== '') { + if (message.typeName !== "") { writer.uint32(50).string(message.typeName); } - if (message.extendee !== '') { + if (message.extendee !== "") { writer.uint32(18).string(message.extendee); } - if (message.defaultValue !== '') { + if (message.defaultValue !== "") { writer.uint32(58).string(message.defaultValue); } if (message.oneofIndex !== 0) { writer.uint32(72).int32(message.oneofIndex); } - if (message.jsonName !== '') { + if (message.jsonName !== "") { writer.uint32(82).string(message.jsonName); } if (message.options !== undefined) { @@ -1322,12 +1331,12 @@ export const FieldDescriptorProto = { }; function createBaseOneofDescriptorProto(): OneofDescriptorProto { - return { name: '', options: undefined }; + return { name: "", options: undefined }; } export const OneofDescriptorProto = { encode(message: OneofDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.options !== undefined) { @@ -1359,12 +1368,12 @@ export const OneofDescriptorProto = { }; function createBaseEnumDescriptorProto(): EnumDescriptorProto { - return { name: '', value: [], options: undefined, reservedRange: [], reservedName: [] }; + return { name: "", value: [], options: undefined, reservedRange: [], reservedName: [] }; } export const EnumDescriptorProto = { encode(message: EnumDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } for (const v of message.value) { @@ -1451,12 +1460,12 @@ export const EnumDescriptorProto_EnumReservedRange = { }; function createBaseEnumValueDescriptorProto(): EnumValueDescriptorProto { - return { name: '', number: 0, options: undefined }; + return { name: "", number: 0, options: undefined }; } export const EnumValueDescriptorProto = { encode(message: EnumValueDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.number !== 0) { @@ -1494,12 +1503,12 @@ export const EnumValueDescriptorProto = { }; function createBaseServiceDescriptorProto(): ServiceDescriptorProto { - return { name: '', method: [], options: undefined }; + return { name: "", method: [], options: undefined }; } export const ServiceDescriptorProto = { encode(message: ServiceDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } for (const v of message.method) { @@ -1538,9 +1547,9 @@ export const ServiceDescriptorProto = { function createBaseMethodDescriptorProto(): MethodDescriptorProto { return { - name: '', - inputType: '', - outputType: '', + name: "", + inputType: "", + outputType: "", options: undefined, clientStreaming: false, serverStreaming: false, @@ -1549,13 +1558,13 @@ function createBaseMethodDescriptorProto(): MethodDescriptorProto { export const MethodDescriptorProto = { encode(message: MethodDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } - if (message.inputType !== '') { + if (message.inputType !== "") { writer.uint32(18).string(message.inputType); } - if (message.outputType !== '') { + if (message.outputType !== "") { writer.uint32(26).string(message.outputType); } if (message.options !== undefined) { @@ -1606,36 +1615,36 @@ export const MethodDescriptorProto = { function createBaseFileOptions(): FileOptions { return { - javaPackage: '', - javaOuterClassname: '', + javaPackage: "", + javaOuterClassname: "", javaMultipleFiles: false, javaGenerateEqualsAndHash: false, javaStringCheckUtf8: false, optimizeFor: 1, - goPackage: '', + goPackage: "", ccGenericServices: false, javaGenericServices: false, pyGenericServices: false, phpGenericServices: false, deprecated: false, ccEnableArenas: false, - objcClassPrefix: '', - csharpNamespace: '', - swiftPrefix: '', - phpClassPrefix: '', - phpNamespace: '', - phpMetadataNamespace: '', - rubyPackage: '', + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", uninterpretedOption: [], }; } export const FileOptions = { encode(message: FileOptions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.javaPackage !== '') { + if (message.javaPackage !== "") { writer.uint32(10).string(message.javaPackage); } - if (message.javaOuterClassname !== '') { + if (message.javaOuterClassname !== "") { writer.uint32(66).string(message.javaOuterClassname); } if (message.javaMultipleFiles === true) { @@ -1650,7 +1659,7 @@ export const FileOptions = { if (message.optimizeFor !== 1) { writer.uint32(72).int32(message.optimizeFor); } - if (message.goPackage !== '') { + if (message.goPackage !== "") { writer.uint32(90).string(message.goPackage); } if (message.ccGenericServices === true) { @@ -1671,25 +1680,25 @@ export const FileOptions = { if (message.ccEnableArenas === true) { writer.uint32(248).bool(message.ccEnableArenas); } - if (message.objcClassPrefix !== '') { + if (message.objcClassPrefix !== "") { writer.uint32(290).string(message.objcClassPrefix); } - if (message.csharpNamespace !== '') { + if (message.csharpNamespace !== "") { writer.uint32(298).string(message.csharpNamespace); } - if (message.swiftPrefix !== '') { + if (message.swiftPrefix !== "") { writer.uint32(314).string(message.swiftPrefix); } - if (message.phpClassPrefix !== '') { + if (message.phpClassPrefix !== "") { writer.uint32(322).string(message.phpClassPrefix); } - if (message.phpNamespace !== '') { + if (message.phpNamespace !== "") { writer.uint32(330).string(message.phpNamespace); } - if (message.phpMetadataNamespace !== '') { + if (message.phpMetadataNamespace !== "") { writer.uint32(354).string(message.phpMetadataNamespace); } - if (message.rubyPackage !== '') { + if (message.rubyPackage !== "") { writer.uint32(362).string(message.rubyPackage); } for (const v of message.uninterpretedOption) { @@ -2099,12 +2108,12 @@ export const MethodOptions = { function createBaseUninterpretedOption(): UninterpretedOption { return { name: [], - identifierValue: '', + identifierValue: "", positiveIntValue: 0, negativeIntValue: 0, doubleValue: 0, stringValue: new Uint8Array(), - aggregateValue: '', + aggregateValue: "", }; } @@ -2113,7 +2122,7 @@ export const UninterpretedOption = { for (const v of message.name) { UninterpretedOption_NamePart.encode(v!, writer.uint32(18).fork()).ldelim(); } - if (message.identifierValue !== '') { + if (message.identifierValue !== "") { writer.uint32(26).string(message.identifierValue); } if (message.positiveIntValue !== 0) { @@ -2128,7 +2137,7 @@ export const UninterpretedOption = { if (message.stringValue.length !== 0) { writer.uint32(58).bytes(message.stringValue); } - if (message.aggregateValue !== '') { + if (message.aggregateValue !== "") { writer.uint32(66).string(message.aggregateValue); } return writer; @@ -2172,12 +2181,12 @@ export const UninterpretedOption = { }; function createBaseUninterpretedOption_NamePart(): UninterpretedOption_NamePart { - return { namePart: '', isExtension: false }; + return { namePart: "", isExtension: false }; } export const UninterpretedOption_NamePart = { encode(message: UninterpretedOption_NamePart, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.namePart !== '') { + if (message.namePart !== "") { writer.uint32(10).string(message.namePart); } if (message.isExtension === true) { @@ -2240,7 +2249,7 @@ export const SourceCodeInfo = { }; function createBaseSourceCodeInfo_Location(): SourceCodeInfo_Location { - return { path: [], span: [], leadingComments: '', trailingComments: '', leadingDetachedComments: [] }; + return { path: [], span: [], leadingComments: "", trailingComments: "", leadingDetachedComments: [] }; } export const SourceCodeInfo_Location = { @@ -2255,10 +2264,10 @@ export const SourceCodeInfo_Location = { writer.int32(v); } writer.ldelim(); - if (message.leadingComments !== '') { + if (message.leadingComments !== "") { writer.uint32(26).string(message.leadingComments); } - if (message.trailingComments !== '') { + if (message.trailingComments !== "") { writer.uint32(34).string(message.trailingComments); } for (const v of message.leadingDetachedComments) { @@ -2344,7 +2353,7 @@ export const GeneratedCodeInfo = { }; function createBaseGeneratedCodeInfo_Annotation(): GeneratedCodeInfo_Annotation { - return { path: [], sourceFile: '', begin: 0, end: 0 }; + return { path: [], sourceFile: "", begin: 0, end: 0 }; } export const GeneratedCodeInfo_Annotation = { @@ -2354,7 +2363,7 @@ export const GeneratedCodeInfo_Annotation = { writer.int32(v); } writer.ldelim(); - if (message.sourceFile !== '') { + if (message.sourceFile !== "") { writer.uint32(18).string(message.sourceFile); } if (message.begin !== 0) { @@ -2415,3153 +2424,2818 @@ export interface ProtoMetadata { options?: { options?: { [key: string]: any }; services?: { - [key: string]: { - options?: { [key: string]: any }; - methods?: { [key: string]: { [key: string]: any } }; - }; - }; - messages?: { - [key: string]: ProtoMetaMessageOptions; - }; - enums?: { - [key: string]: { - options?: { [key: string]: any }; - values?: { [key: string]: { [key: string]: any } }; - }; + [key: string]: { options?: { [key: string]: any }; methods?: { [key: string]: { [key: string]: any } } }; }; + messages?: { [key: string]: ProtoMetaMessageOptions }; + enums?: { [key: string]: { options?: { [key: string]: any }; values?: { [key: string]: { [key: string]: any } } } }; }; } export const protoMetadata: ProtoMetadata = { fileDescriptor: FileDescriptorProto1.fromPartial({ - name: 'google/protobuf/descriptor.proto', - package: 'google.protobuf', - dependency: [], - publicDependency: [], - weakDependency: [], - messageType: [ - { - name: 'FileDescriptorSet', - field: [ - { - name: 'file', - number: 1, - label: 3, - type: 11, - typeName: '.google.protobuf.FileDescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'file', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'FileDescriptorProto', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'package', - number: 2, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'package', - options: undefined, - proto3Optional: false, - }, - { - name: 'dependency', - number: 3, - label: 3, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'dependency', - options: undefined, - proto3Optional: false, - }, - { - name: 'public_dependency', - number: 10, - label: 3, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'publicDependency', - options: undefined, - proto3Optional: false, - }, - { - name: 'weak_dependency', - number: 11, - label: 3, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'weakDependency', - options: undefined, - proto3Optional: false, - }, - { - name: 'message_type', - number: 4, - label: 3, - type: 11, - typeName: '.google.protobuf.DescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'messageType', - options: undefined, - proto3Optional: false, - }, - { - name: 'enum_type', - number: 5, - label: 3, - type: 11, - typeName: '.google.protobuf.EnumDescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'enumType', - options: undefined, - proto3Optional: false, - }, - { - name: 'service', - number: 6, - label: 3, - type: 11, - typeName: '.google.protobuf.ServiceDescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'service', - options: undefined, - proto3Optional: false, - }, - { - name: 'extension', - number: 7, - label: 3, - type: 11, - typeName: '.google.protobuf.FieldDescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'extension', - options: undefined, - proto3Optional: false, - }, - { - name: 'options', - number: 8, - label: 1, - type: 11, - typeName: '.google.protobuf.FileOptions', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'options', - options: undefined, - proto3Optional: false, - }, - { - name: 'source_code_info', - number: 9, - label: 1, - type: 11, - typeName: '.google.protobuf.SourceCodeInfo', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'sourceCodeInfo', - options: undefined, - proto3Optional: false, - }, - { - name: 'syntax', - number: 12, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'syntax', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'DescriptorProto', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'field', - number: 2, - label: 3, - type: 11, - typeName: '.google.protobuf.FieldDescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'field', - options: undefined, - proto3Optional: false, - }, - { - name: 'extension', - number: 6, - label: 3, - type: 11, - typeName: '.google.protobuf.FieldDescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'extension', - options: undefined, - proto3Optional: false, - }, - { - name: 'nested_type', - number: 3, - label: 3, - type: 11, - typeName: '.google.protobuf.DescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'nestedType', - options: undefined, - proto3Optional: false, - }, - { - name: 'enum_type', - number: 4, - label: 3, - type: 11, - typeName: '.google.protobuf.EnumDescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'enumType', - options: undefined, - proto3Optional: false, - }, - { - name: 'extension_range', - number: 5, - label: 3, - type: 11, - typeName: '.google.protobuf.DescriptorProto.ExtensionRange', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'extensionRange', - options: undefined, - proto3Optional: false, - }, - { - name: 'oneof_decl', - number: 8, - label: 3, - type: 11, - typeName: '.google.protobuf.OneofDescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'oneofDecl', - options: undefined, - proto3Optional: false, - }, - { - name: 'options', - number: 7, - label: 1, - type: 11, - typeName: '.google.protobuf.MessageOptions', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'options', - options: undefined, - proto3Optional: false, - }, - { - name: 'reserved_range', - number: 9, - label: 3, - type: 11, - typeName: '.google.protobuf.DescriptorProto.ReservedRange', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'reservedRange', - options: undefined, - proto3Optional: false, - }, - { - name: 'reserved_name', - number: 10, - label: 3, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'reservedName', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [ - { - name: 'ExtensionRange', - field: [ - { - name: 'start', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'start', - options: undefined, - proto3Optional: false, - }, - { - name: 'end', - number: 2, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'end', - options: undefined, - proto3Optional: false, - }, - { - name: 'options', - number: 3, - label: 1, - type: 11, - typeName: '.google.protobuf.ExtensionRangeOptions', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'options', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'ReservedRange', - field: [ - { - name: 'start', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'start', - options: undefined, - proto3Optional: false, - }, - { - name: 'end', - number: 2, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'end', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'ExtensionRangeOptions', - field: [ - { - name: 'uninterpreted_option', - number: 999, - label: 3, - type: 11, - typeName: '.google.protobuf.UninterpretedOption', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uninterpretedOption', - options: undefined, - proto3Optional: false, - }, + "name": "google/protobuf/descriptor.proto", + "package": "google.protobuf", + "dependency": [], + "publicDependency": [], + "weakDependency": [], + "messageType": [{ + "name": "FileDescriptorSet", + "field": [{ + "name": "file", + "number": 1, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.FileDescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "file", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "FileDescriptorProto", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "package", + "number": 2, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "package", + "options": undefined, + "proto3Optional": false, + }, { + "name": "dependency", + "number": 3, + "label": 3, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "dependency", + "options": undefined, + "proto3Optional": false, + }, { + "name": "public_dependency", + "number": 10, + "label": 3, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "publicDependency", + "options": undefined, + "proto3Optional": false, + }, { + "name": "weak_dependency", + "number": 11, + "label": 3, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "weakDependency", + "options": undefined, + "proto3Optional": false, + }, { + "name": "message_type", + "number": 4, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.DescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "messageType", + "options": undefined, + "proto3Optional": false, + }, { + "name": "enum_type", + "number": 5, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.EnumDescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "enumType", + "options": undefined, + "proto3Optional": false, + }, { + "name": "service", + "number": 6, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.ServiceDescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "service", + "options": undefined, + "proto3Optional": false, + }, { + "name": "extension", + "number": 7, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.FieldDescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "extension", + "options": undefined, + "proto3Optional": false, + }, { + "name": "options", + "number": 8, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.FileOptions", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "options", + "options": undefined, + "proto3Optional": false, + }, { + "name": "source_code_info", + "number": 9, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.SourceCodeInfo", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "sourceCodeInfo", + "options": undefined, + "proto3Optional": false, + }, { + "name": "syntax", + "number": 12, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "syntax", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "DescriptorProto", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "field", + "number": 2, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.FieldDescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "field", + "options": undefined, + "proto3Optional": false, + }, { + "name": "extension", + "number": 6, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.FieldDescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "extension", + "options": undefined, + "proto3Optional": false, + }, { + "name": "nested_type", + "number": 3, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.DescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "nestedType", + "options": undefined, + "proto3Optional": false, + }, { + "name": "enum_type", + "number": 4, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.EnumDescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "enumType", + "options": undefined, + "proto3Optional": false, + }, { + "name": "extension_range", + "number": 5, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.DescriptorProto.ExtensionRange", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "extensionRange", + "options": undefined, + "proto3Optional": false, + }, { + "name": "oneof_decl", + "number": 8, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.OneofDescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "oneofDecl", + "options": undefined, + "proto3Optional": false, + }, { + "name": "options", + "number": 7, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.MessageOptions", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "options", + "options": undefined, + "proto3Optional": false, + }, { + "name": "reserved_range", + "number": 9, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.DescriptorProto.ReservedRange", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "reservedRange", + "options": undefined, + "proto3Optional": false, + }, { + "name": "reserved_name", + "number": 10, + "label": 3, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "reservedName", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [{ + "name": "ExtensionRange", + "field": [{ + "name": "start", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "start", + "options": undefined, + "proto3Optional": false, + }, { + "name": "end", + "number": 2, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "end", + "options": undefined, + "proto3Optional": false, + }, { + "name": "options", + "number": 3, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.ExtensionRangeOptions", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "options", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "ReservedRange", + "field": [{ + "name": "start", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "start", + "options": undefined, + "proto3Optional": false, + }, { + "name": "end", + "number": 2, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "end", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "ExtensionRangeOptions", + "field": [{ + "name": "uninterpreted_option", + "number": 999, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.UninterpretedOption", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uninterpretedOption", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [{ "start": 1000, "end": 536870912, "options": undefined }], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "FieldDescriptorProto", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "number", + "number": 3, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "number", + "options": undefined, + "proto3Optional": false, + }, { + "name": "label", + "number": 4, + "label": 1, + "type": 14, + "typeName": ".google.protobuf.FieldDescriptorProto.Label", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "label", + "options": undefined, + "proto3Optional": false, + }, { + "name": "type", + "number": 5, + "label": 1, + "type": 14, + "typeName": ".google.protobuf.FieldDescriptorProto.Type", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "type", + "options": undefined, + "proto3Optional": false, + }, { + "name": "type_name", + "number": 6, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "typeName", + "options": undefined, + "proto3Optional": false, + }, { + "name": "extendee", + "number": 2, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "extendee", + "options": undefined, + "proto3Optional": false, + }, { + "name": "default_value", + "number": 7, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "defaultValue", + "options": undefined, + "proto3Optional": false, + }, { + "name": "oneof_index", + "number": 9, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "oneofIndex", + "options": undefined, + "proto3Optional": false, + }, { + "name": "json_name", + "number": 10, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "jsonName", + "options": undefined, + "proto3Optional": false, + }, { + "name": "options", + "number": 8, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.FieldOptions", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "options", + "options": undefined, + "proto3Optional": false, + }, { + "name": "proto3_optional", + "number": 17, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "proto3Optional", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [{ + "name": "Type", + "value": [ + { "name": "TYPE_DOUBLE", "number": 1, "options": undefined }, + { "name": "TYPE_FLOAT", "number": 2, "options": undefined }, + { "name": "TYPE_INT64", "number": 3, "options": undefined }, + { "name": "TYPE_UINT64", "number": 4, "options": undefined }, + { "name": "TYPE_INT32", "number": 5, "options": undefined }, + { "name": "TYPE_FIXED64", "number": 6, "options": undefined }, + { "name": "TYPE_FIXED32", "number": 7, "options": undefined }, + { "name": "TYPE_BOOL", "number": 8, "options": undefined }, + { "name": "TYPE_STRING", "number": 9, "options": undefined }, + { "name": "TYPE_GROUP", "number": 10, "options": undefined }, + { "name": "TYPE_MESSAGE", "number": 11, "options": undefined }, + { "name": "TYPE_BYTES", "number": 12, "options": undefined }, + { "name": "TYPE_UINT32", "number": 13, "options": undefined }, + { "name": "TYPE_ENUM", "number": 14, "options": undefined }, + { "name": "TYPE_SFIXED32", "number": 15, "options": undefined }, + { "name": "TYPE_SFIXED64", "number": 16, "options": undefined }, + { "name": "TYPE_SINT32", "number": 17, "options": undefined }, + { "name": "TYPE_SINT64", "number": 18, "options": undefined }, ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [{ start: 1000, end: 536870912, options: undefined }], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'FieldDescriptorProto', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'number', - number: 3, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'number', - options: undefined, - proto3Optional: false, - }, - { - name: 'label', - number: 4, - label: 1, - type: 14, - typeName: '.google.protobuf.FieldDescriptorProto.Label', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'label', - options: undefined, - proto3Optional: false, - }, - { - name: 'type', - number: 5, - label: 1, - type: 14, - typeName: '.google.protobuf.FieldDescriptorProto.Type', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'type', - options: undefined, - proto3Optional: false, - }, - { - name: 'type_name', - number: 6, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'typeName', - options: undefined, - proto3Optional: false, - }, - { - name: 'extendee', - number: 2, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'extendee', - options: undefined, - proto3Optional: false, - }, - { - name: 'default_value', - number: 7, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'defaultValue', - options: undefined, - proto3Optional: false, - }, - { - name: 'oneof_index', - number: 9, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'oneofIndex', - options: undefined, - proto3Optional: false, - }, - { - name: 'json_name', - number: 10, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'jsonName', - options: undefined, - proto3Optional: false, - }, - { - name: 'options', - number: 8, - label: 1, - type: 11, - typeName: '.google.protobuf.FieldOptions', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'options', - options: undefined, - proto3Optional: false, - }, - { - name: 'proto3_optional', - number: 17, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'proto3Optional', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [ - { - name: 'Type', - value: [ - { name: 'TYPE_DOUBLE', number: 1, options: undefined }, - { name: 'TYPE_FLOAT', number: 2, options: undefined }, - { name: 'TYPE_INT64', number: 3, options: undefined }, - { name: 'TYPE_UINT64', number: 4, options: undefined }, - { name: 'TYPE_INT32', number: 5, options: undefined }, - { name: 'TYPE_FIXED64', number: 6, options: undefined }, - { name: 'TYPE_FIXED32', number: 7, options: undefined }, - { name: 'TYPE_BOOL', number: 8, options: undefined }, - { name: 'TYPE_STRING', number: 9, options: undefined }, - { name: 'TYPE_GROUP', number: 10, options: undefined }, - { name: 'TYPE_MESSAGE', number: 11, options: undefined }, - { name: 'TYPE_BYTES', number: 12, options: undefined }, - { name: 'TYPE_UINT32', number: 13, options: undefined }, - { name: 'TYPE_ENUM', number: 14, options: undefined }, - { name: 'TYPE_SFIXED32', number: 15, options: undefined }, - { name: 'TYPE_SFIXED64', number: 16, options: undefined }, - { name: 'TYPE_SINT32', number: 17, options: undefined }, - { name: 'TYPE_SINT64', number: 18, options: undefined }, - ], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'Label', - value: [ - { name: 'LABEL_OPTIONAL', number: 1, options: undefined }, - { name: 'LABEL_REQUIRED', number: 2, options: undefined }, - { name: 'LABEL_REPEATED', number: 3, options: undefined }, - ], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'OneofDescriptorProto', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'options', - number: 2, - label: 1, - type: 11, - typeName: '.google.protobuf.OneofOptions', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'options', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'EnumDescriptorProto', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'value', - number: 2, - label: 3, - type: 11, - typeName: '.google.protobuf.EnumValueDescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'value', - options: undefined, - proto3Optional: false, - }, - { - name: 'options', - number: 3, - label: 1, - type: 11, - typeName: '.google.protobuf.EnumOptions', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'options', - options: undefined, - proto3Optional: false, - }, - { - name: 'reserved_range', - number: 4, - label: 3, - type: 11, - typeName: '.google.protobuf.EnumDescriptorProto.EnumReservedRange', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'reservedRange', - options: undefined, - proto3Optional: false, - }, - { - name: 'reserved_name', - number: 5, - label: 3, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'reservedName', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [ - { - name: 'EnumReservedRange', - field: [ - { - name: 'start', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'start', - options: undefined, - proto3Optional: false, - }, - { - name: 'end', - number: 2, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'end', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'EnumValueDescriptorProto', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'number', - number: 2, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'number', - options: undefined, - proto3Optional: false, - }, - { - name: 'options', - number: 3, - label: 1, - type: 11, - typeName: '.google.protobuf.EnumValueOptions', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'options', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'ServiceDescriptorProto', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'method', - number: 2, - label: 3, - type: 11, - typeName: '.google.protobuf.MethodDescriptorProto', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'method', - options: undefined, - proto3Optional: false, - }, - { - name: 'options', - number: 3, - label: 1, - type: 11, - typeName: '.google.protobuf.ServiceOptions', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'options', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'MethodDescriptorProto', - field: [ - { - name: 'name', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'input_type', - number: 2, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'inputType', - options: undefined, - proto3Optional: false, - }, - { - name: 'output_type', - number: 3, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'outputType', - options: undefined, - proto3Optional: false, - }, - { - name: 'options', - number: 4, - label: 1, - type: 11, - typeName: '.google.protobuf.MethodOptions', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'options', - options: undefined, - proto3Optional: false, - }, - { - name: 'client_streaming', - number: 5, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'clientStreaming', - options: undefined, - proto3Optional: false, - }, - { - name: 'server_streaming', - number: 6, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'serverStreaming', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'FileOptions', - field: [ - { - name: 'java_package', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'javaPackage', - options: undefined, - proto3Optional: false, - }, - { - name: 'java_outer_classname', - number: 8, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'javaOuterClassname', - options: undefined, - proto3Optional: false, - }, - { - name: 'java_multiple_files', - number: 10, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'javaMultipleFiles', - options: undefined, - proto3Optional: false, - }, - { - name: 'java_generate_equals_and_hash', - number: 20, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'javaGenerateEqualsAndHash', - options: { - ctype: 0, - packed: false, - jstype: 0, - lazy: false, - deprecated: true, - weak: false, - uninterpretedOption: [], - }, - proto3Optional: false, - }, - { - name: 'java_string_check_utf8', - number: 27, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'javaStringCheckUtf8', - options: undefined, - proto3Optional: false, - }, - { - name: 'optimize_for', - number: 9, - label: 1, - type: 14, - typeName: '.google.protobuf.FileOptions.OptimizeMode', - extendee: '', - defaultValue: 'SPEED', - oneofIndex: 0, - jsonName: 'optimizeFor', - options: undefined, - proto3Optional: false, - }, - { - name: 'go_package', - number: 11, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'goPackage', - options: undefined, - proto3Optional: false, - }, - { - name: 'cc_generic_services', - number: 16, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'ccGenericServices', - options: undefined, - proto3Optional: false, - }, - { - name: 'java_generic_services', - number: 17, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'javaGenericServices', - options: undefined, - proto3Optional: false, - }, - { - name: 'py_generic_services', - number: 18, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'pyGenericServices', - options: undefined, - proto3Optional: false, - }, - { - name: 'php_generic_services', - number: 42, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'phpGenericServices', - options: undefined, - proto3Optional: false, - }, - { - name: 'deprecated', - number: 23, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'deprecated', - options: undefined, - proto3Optional: false, - }, - { - name: 'cc_enable_arenas', - number: 31, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'true', - oneofIndex: 0, - jsonName: 'ccEnableArenas', - options: undefined, - proto3Optional: false, - }, - { - name: 'objc_class_prefix', - number: 36, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'objcClassPrefix', - options: undefined, - proto3Optional: false, - }, - { - name: 'csharp_namespace', - number: 37, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'csharpNamespace', - options: undefined, - proto3Optional: false, - }, - { - name: 'swift_prefix', - number: 39, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'swiftPrefix', - options: undefined, - proto3Optional: false, - }, - { - name: 'php_class_prefix', - number: 40, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'phpClassPrefix', - options: undefined, - proto3Optional: false, - }, - { - name: 'php_namespace', - number: 41, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'phpNamespace', - options: undefined, - proto3Optional: false, - }, - { - name: 'php_metadata_namespace', - number: 44, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'phpMetadataNamespace', - options: undefined, - proto3Optional: false, - }, - { - name: 'ruby_package', - number: 45, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'rubyPackage', - options: undefined, - proto3Optional: false, - }, - { - name: 'uninterpreted_option', - number: 999, - label: 3, - type: 11, - typeName: '.google.protobuf.UninterpretedOption', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uninterpretedOption', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [ - { - name: 'OptimizeMode', - value: [ - { name: 'SPEED', number: 1, options: undefined }, - { name: 'CODE_SIZE', number: 2, options: undefined }, - { name: 'LITE_RUNTIME', number: 3, options: undefined }, - ], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - extensionRange: [{ start: 1000, end: 536870912, options: undefined }], - oneofDecl: [], - options: undefined, - reservedRange: [{ start: 38, end: 39 }], - reservedName: [], - }, - { - name: 'MessageOptions', - field: [ - { - name: 'message_set_wire_format', - number: 1, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'messageSetWireFormat', - options: undefined, - proto3Optional: false, - }, - { - name: 'no_standard_descriptor_accessor', - number: 2, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'noStandardDescriptorAccessor', - options: undefined, - proto3Optional: false, - }, - { - name: 'deprecated', - number: 3, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'deprecated', - options: undefined, - proto3Optional: false, - }, - { - name: 'map_entry', - number: 7, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'mapEntry', - options: undefined, - proto3Optional: false, - }, - { - name: 'uninterpreted_option', - number: 999, - label: 3, - type: 11, - typeName: '.google.protobuf.UninterpretedOption', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uninterpretedOption', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [{ start: 1000, end: 536870912, options: undefined }], - oneofDecl: [], - options: undefined, - reservedRange: [ - { start: 4, end: 5 }, - { start: 5, end: 6 }, - { start: 6, end: 7 }, - { start: 8, end: 9 }, - { start: 9, end: 10 }, - ], - reservedName: [], - }, - { - name: 'FieldOptions', - field: [ - { - name: 'ctype', - number: 1, - label: 1, - type: 14, - typeName: '.google.protobuf.FieldOptions.CType', - extendee: '', - defaultValue: 'STRING', - oneofIndex: 0, - jsonName: 'ctype', - options: undefined, - proto3Optional: false, - }, - { - name: 'packed', - number: 2, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'packed', - options: undefined, - proto3Optional: false, - }, - { - name: 'jstype', - number: 6, - label: 1, - type: 14, - typeName: '.google.protobuf.FieldOptions.JSType', - extendee: '', - defaultValue: 'JS_NORMAL', - oneofIndex: 0, - jsonName: 'jstype', - options: undefined, - proto3Optional: false, - }, - { - name: 'lazy', - number: 5, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'lazy', - options: undefined, - proto3Optional: false, - }, - { - name: 'deprecated', - number: 3, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'deprecated', - options: undefined, - proto3Optional: false, - }, - { - name: 'weak', - number: 10, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'weak', - options: undefined, - proto3Optional: false, - }, - { - name: 'uninterpreted_option', - number: 999, - label: 3, - type: 11, - typeName: '.google.protobuf.UninterpretedOption', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uninterpretedOption', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [ - { - name: 'CType', - value: [ - { name: 'STRING', number: 0, options: undefined }, - { name: 'CORD', number: 1, options: undefined }, - { name: 'STRING_PIECE', number: 2, options: undefined }, - ], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'JSType', - value: [ - { name: 'JS_NORMAL', number: 0, options: undefined }, - { name: 'JS_STRING', number: 1, options: undefined }, - { name: 'JS_NUMBER', number: 2, options: undefined }, - ], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - extensionRange: [{ start: 1000, end: 536870912, options: undefined }], - oneofDecl: [], - options: undefined, - reservedRange: [{ start: 4, end: 5 }], - reservedName: [], - }, - { - name: 'OneofOptions', - field: [ - { - name: 'uninterpreted_option', - number: 999, - label: 3, - type: 11, - typeName: '.google.protobuf.UninterpretedOption', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uninterpretedOption', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [{ start: 1000, end: 536870912, options: undefined }], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'EnumOptions', - field: [ - { - name: 'allow_alias', - number: 2, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'allowAlias', - options: undefined, - proto3Optional: false, - }, - { - name: 'deprecated', - number: 3, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'deprecated', - options: undefined, - proto3Optional: false, - }, - { - name: 'uninterpreted_option', - number: 999, - label: 3, - type: 11, - typeName: '.google.protobuf.UninterpretedOption', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uninterpretedOption', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [{ start: 1000, end: 536870912, options: undefined }], - oneofDecl: [], - options: undefined, - reservedRange: [{ start: 5, end: 6 }], - reservedName: [], - }, - { - name: 'EnumValueOptions', - field: [ - { - name: 'deprecated', - number: 1, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'deprecated', - options: undefined, - proto3Optional: false, - }, - { - name: 'uninterpreted_option', - number: 999, - label: 3, - type: 11, - typeName: '.google.protobuf.UninterpretedOption', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uninterpretedOption', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [{ start: 1000, end: 536870912, options: undefined }], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'ServiceOptions', - field: [ - { - name: 'deprecated', - number: 33, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'deprecated', - options: undefined, - proto3Optional: false, - }, - { - name: 'uninterpreted_option', - number: 999, - label: 3, - type: 11, - typeName: '.google.protobuf.UninterpretedOption', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uninterpretedOption', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [{ start: 1000, end: 536870912, options: undefined }], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'MethodOptions', - field: [ - { - name: 'deprecated', - number: 33, - label: 1, - type: 8, - typeName: '', - extendee: '', - defaultValue: 'false', - oneofIndex: 0, - jsonName: 'deprecated', - options: undefined, - proto3Optional: false, - }, - { - name: 'idempotency_level', - number: 34, - label: 1, - type: 14, - typeName: '.google.protobuf.MethodOptions.IdempotencyLevel', - extendee: '', - defaultValue: 'IDEMPOTENCY_UNKNOWN', - oneofIndex: 0, - jsonName: 'idempotencyLevel', - options: undefined, - proto3Optional: false, - }, - { - name: 'uninterpreted_option', - number: 999, - label: 3, - type: 11, - typeName: '.google.protobuf.UninterpretedOption', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'uninterpretedOption', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [ - { - name: 'IdempotencyLevel', - value: [ - { name: 'IDEMPOTENCY_UNKNOWN', number: 0, options: undefined }, - { name: 'NO_SIDE_EFFECTS', number: 1, options: undefined }, - { name: 'IDEMPOTENT', number: 2, options: undefined }, - ], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - extensionRange: [{ start: 1000, end: 536870912, options: undefined }], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'UninterpretedOption', - field: [ - { - name: 'name', - number: 2, - label: 3, - type: 11, - typeName: '.google.protobuf.UninterpretedOption.NamePart', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'name', - options: undefined, - proto3Optional: false, - }, - { - name: 'identifier_value', - number: 3, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'identifierValue', - options: undefined, - proto3Optional: false, - }, - { - name: 'positive_int_value', - number: 4, - label: 1, - type: 4, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'positiveIntValue', - options: undefined, - proto3Optional: false, - }, - { - name: 'negative_int_value', - number: 5, - label: 1, - type: 3, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'negativeIntValue', - options: undefined, - proto3Optional: false, - }, - { - name: 'double_value', - number: 6, - label: 1, - type: 1, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'doubleValue', - options: undefined, - proto3Optional: false, - }, - { - name: 'string_value', - number: 7, - label: 1, - type: 12, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'stringValue', - options: undefined, - proto3Optional: false, - }, - { - name: 'aggregate_value', - number: 8, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'aggregateValue', - options: undefined, - proto3Optional: false, + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "Label", + "value": [{ "name": "LABEL_OPTIONAL", "number": 1, "options": undefined }, { + "name": "LABEL_REQUIRED", + "number": 2, + "options": undefined, + }, { "name": "LABEL_REPEATED", "number": 3, "options": undefined }], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "OneofDescriptorProto", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "options", + "number": 2, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.OneofOptions", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "options", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "EnumDescriptorProto", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "value", + "number": 2, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.EnumValueDescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "value", + "options": undefined, + "proto3Optional": false, + }, { + "name": "options", + "number": 3, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.EnumOptions", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "options", + "options": undefined, + "proto3Optional": false, + }, { + "name": "reserved_range", + "number": 4, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.EnumDescriptorProto.EnumReservedRange", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "reservedRange", + "options": undefined, + "proto3Optional": false, + }, { + "name": "reserved_name", + "number": 5, + "label": 3, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "reservedName", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [{ + "name": "EnumReservedRange", + "field": [{ + "name": "start", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "start", + "options": undefined, + "proto3Optional": false, + }, { + "name": "end", + "number": 2, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "end", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "EnumValueDescriptorProto", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "number", + "number": 2, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "number", + "options": undefined, + "proto3Optional": false, + }, { + "name": "options", + "number": 3, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.EnumValueOptions", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "options", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "ServiceDescriptorProto", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "method", + "number": 2, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.MethodDescriptorProto", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "method", + "options": undefined, + "proto3Optional": false, + }, { + "name": "options", + "number": 3, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.ServiceOptions", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "options", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "MethodDescriptorProto", + "field": [{ + "name": "name", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "input_type", + "number": 2, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "inputType", + "options": undefined, + "proto3Optional": false, + }, { + "name": "output_type", + "number": 3, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "outputType", + "options": undefined, + "proto3Optional": false, + }, { + "name": "options", + "number": 4, + "label": 1, + "type": 11, + "typeName": ".google.protobuf.MethodOptions", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "options", + "options": undefined, + "proto3Optional": false, + }, { + "name": "client_streaming", + "number": 5, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "clientStreaming", + "options": undefined, + "proto3Optional": false, + }, { + "name": "server_streaming", + "number": 6, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "serverStreaming", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "FileOptions", + "field": [{ + "name": "java_package", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "javaPackage", + "options": undefined, + "proto3Optional": false, + }, { + "name": "java_outer_classname", + "number": 8, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "javaOuterClassname", + "options": undefined, + "proto3Optional": false, + }, { + "name": "java_multiple_files", + "number": 10, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "javaMultipleFiles", + "options": undefined, + "proto3Optional": false, + }, { + "name": "java_generate_equals_and_hash", + "number": 20, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "javaGenerateEqualsAndHash", + "options": { + "ctype": 0, + "packed": false, + "jstype": 0, + "lazy": false, + "deprecated": true, + "weak": false, + "uninterpretedOption": [], + }, + "proto3Optional": false, + }, { + "name": "java_string_check_utf8", + "number": 27, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "javaStringCheckUtf8", + "options": undefined, + "proto3Optional": false, + }, { + "name": "optimize_for", + "number": 9, + "label": 1, + "type": 14, + "typeName": ".google.protobuf.FileOptions.OptimizeMode", + "extendee": "", + "defaultValue": "SPEED", + "oneofIndex": 0, + "jsonName": "optimizeFor", + "options": undefined, + "proto3Optional": false, + }, { + "name": "go_package", + "number": 11, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "goPackage", + "options": undefined, + "proto3Optional": false, + }, { + "name": "cc_generic_services", + "number": 16, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "ccGenericServices", + "options": undefined, + "proto3Optional": false, + }, { + "name": "java_generic_services", + "number": 17, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "javaGenericServices", + "options": undefined, + "proto3Optional": false, + }, { + "name": "py_generic_services", + "number": 18, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "pyGenericServices", + "options": undefined, + "proto3Optional": false, + }, { + "name": "php_generic_services", + "number": 42, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "phpGenericServices", + "options": undefined, + "proto3Optional": false, + }, { + "name": "deprecated", + "number": 23, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "deprecated", + "options": undefined, + "proto3Optional": false, + }, { + "name": "cc_enable_arenas", + "number": 31, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "true", + "oneofIndex": 0, + "jsonName": "ccEnableArenas", + "options": undefined, + "proto3Optional": false, + }, { + "name": "objc_class_prefix", + "number": 36, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "objcClassPrefix", + "options": undefined, + "proto3Optional": false, + }, { + "name": "csharp_namespace", + "number": 37, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "csharpNamespace", + "options": undefined, + "proto3Optional": false, + }, { + "name": "swift_prefix", + "number": 39, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "swiftPrefix", + "options": undefined, + "proto3Optional": false, + }, { + "name": "php_class_prefix", + "number": 40, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "phpClassPrefix", + "options": undefined, + "proto3Optional": false, + }, { + "name": "php_namespace", + "number": 41, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "phpNamespace", + "options": undefined, + "proto3Optional": false, + }, { + "name": "php_metadata_namespace", + "number": 44, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "phpMetadataNamespace", + "options": undefined, + "proto3Optional": false, + }, { + "name": "ruby_package", + "number": 45, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "rubyPackage", + "options": undefined, + "proto3Optional": false, + }, { + "name": "uninterpreted_option", + "number": 999, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.UninterpretedOption", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uninterpretedOption", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [{ + "name": "OptimizeMode", + "value": [{ "name": "SPEED", "number": 1, "options": undefined }, { + "name": "CODE_SIZE", + "number": 2, + "options": undefined, + }, { "name": "LITE_RUNTIME", "number": 3, "options": undefined }], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "extensionRange": [{ "start": 1000, "end": 536870912, "options": undefined }], + "oneofDecl": [], + "options": undefined, + "reservedRange": [{ "start": 38, "end": 39 }], + "reservedName": [], + }, { + "name": "MessageOptions", + "field": [{ + "name": "message_set_wire_format", + "number": 1, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "messageSetWireFormat", + "options": undefined, + "proto3Optional": false, + }, { + "name": "no_standard_descriptor_accessor", + "number": 2, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "noStandardDescriptorAccessor", + "options": undefined, + "proto3Optional": false, + }, { + "name": "deprecated", + "number": 3, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "deprecated", + "options": undefined, + "proto3Optional": false, + }, { + "name": "map_entry", + "number": 7, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "mapEntry", + "options": undefined, + "proto3Optional": false, + }, { + "name": "uninterpreted_option", + "number": 999, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.UninterpretedOption", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uninterpretedOption", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [{ "start": 1000, "end": 536870912, "options": undefined }], + "oneofDecl": [], + "options": undefined, + "reservedRange": [{ "start": 4, "end": 5 }, { "start": 5, "end": 6 }, { "start": 6, "end": 7 }, { + "start": 8, + "end": 9, + }, { "start": 9, "end": 10 }], + "reservedName": [], + }, { + "name": "FieldOptions", + "field": [{ + "name": "ctype", + "number": 1, + "label": 1, + "type": 14, + "typeName": ".google.protobuf.FieldOptions.CType", + "extendee": "", + "defaultValue": "STRING", + "oneofIndex": 0, + "jsonName": "ctype", + "options": undefined, + "proto3Optional": false, + }, { + "name": "packed", + "number": 2, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "packed", + "options": undefined, + "proto3Optional": false, + }, { + "name": "jstype", + "number": 6, + "label": 1, + "type": 14, + "typeName": ".google.protobuf.FieldOptions.JSType", + "extendee": "", + "defaultValue": "JS_NORMAL", + "oneofIndex": 0, + "jsonName": "jstype", + "options": undefined, + "proto3Optional": false, + }, { + "name": "lazy", + "number": 5, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "lazy", + "options": undefined, + "proto3Optional": false, + }, { + "name": "deprecated", + "number": 3, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "deprecated", + "options": undefined, + "proto3Optional": false, + }, { + "name": "weak", + "number": 10, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "weak", + "options": undefined, + "proto3Optional": false, + }, { + "name": "uninterpreted_option", + "number": 999, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.UninterpretedOption", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uninterpretedOption", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [{ + "name": "CType", + "value": [{ "name": "STRING", "number": 0, "options": undefined }, { + "name": "CORD", + "number": 1, + "options": undefined, + }, { "name": "STRING_PIECE", "number": 2, "options": undefined }], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "JSType", + "value": [{ "name": "JS_NORMAL", "number": 0, "options": undefined }, { + "name": "JS_STRING", + "number": 1, + "options": undefined, + }, { "name": "JS_NUMBER", "number": 2, "options": undefined }], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "extensionRange": [{ "start": 1000, "end": 536870912, "options": undefined }], + "oneofDecl": [], + "options": undefined, + "reservedRange": [{ "start": 4, "end": 5 }], + "reservedName": [], + }, { + "name": "OneofOptions", + "field": [{ + "name": "uninterpreted_option", + "number": 999, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.UninterpretedOption", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uninterpretedOption", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [{ "start": 1000, "end": 536870912, "options": undefined }], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "EnumOptions", + "field": [{ + "name": "allow_alias", + "number": 2, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "allowAlias", + "options": undefined, + "proto3Optional": false, + }, { + "name": "deprecated", + "number": 3, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "deprecated", + "options": undefined, + "proto3Optional": false, + }, { + "name": "uninterpreted_option", + "number": 999, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.UninterpretedOption", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uninterpretedOption", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [{ "start": 1000, "end": 536870912, "options": undefined }], + "oneofDecl": [], + "options": undefined, + "reservedRange": [{ "start": 5, "end": 6 }], + "reservedName": [], + }, { + "name": "EnumValueOptions", + "field": [{ + "name": "deprecated", + "number": 1, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "deprecated", + "options": undefined, + "proto3Optional": false, + }, { + "name": "uninterpreted_option", + "number": 999, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.UninterpretedOption", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uninterpretedOption", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [{ "start": 1000, "end": 536870912, "options": undefined }], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "ServiceOptions", + "field": [{ + "name": "deprecated", + "number": 33, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "deprecated", + "options": undefined, + "proto3Optional": false, + }, { + "name": "uninterpreted_option", + "number": 999, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.UninterpretedOption", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uninterpretedOption", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [{ "start": 1000, "end": 536870912, "options": undefined }], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "MethodOptions", + "field": [{ + "name": "deprecated", + "number": 33, + "label": 1, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "false", + "oneofIndex": 0, + "jsonName": "deprecated", + "options": undefined, + "proto3Optional": false, + }, { + "name": "idempotency_level", + "number": 34, + "label": 1, + "type": 14, + "typeName": ".google.protobuf.MethodOptions.IdempotencyLevel", + "extendee": "", + "defaultValue": "IDEMPOTENCY_UNKNOWN", + "oneofIndex": 0, + "jsonName": "idempotencyLevel", + "options": undefined, + "proto3Optional": false, + }, { + "name": "uninterpreted_option", + "number": 999, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.UninterpretedOption", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "uninterpretedOption", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [{ + "name": "IdempotencyLevel", + "value": [{ "name": "IDEMPOTENCY_UNKNOWN", "number": 0, "options": undefined }, { + "name": "NO_SIDE_EFFECTS", + "number": 1, + "options": undefined, + }, { "name": "IDEMPOTENT", "number": 2, "options": undefined }], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "extensionRange": [{ "start": 1000, "end": 536870912, "options": undefined }], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "UninterpretedOption", + "field": [{ + "name": "name", + "number": 2, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.UninterpretedOption.NamePart", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "name", + "options": undefined, + "proto3Optional": false, + }, { + "name": "identifier_value", + "number": 3, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "identifierValue", + "options": undefined, + "proto3Optional": false, + }, { + "name": "positive_int_value", + "number": 4, + "label": 1, + "type": 4, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "positiveIntValue", + "options": undefined, + "proto3Optional": false, + }, { + "name": "negative_int_value", + "number": 5, + "label": 1, + "type": 3, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "negativeIntValue", + "options": undefined, + "proto3Optional": false, + }, { + "name": "double_value", + "number": 6, + "label": 1, + "type": 1, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "doubleValue", + "options": undefined, + "proto3Optional": false, + }, { + "name": "string_value", + "number": 7, + "label": 1, + "type": 12, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "stringValue", + "options": undefined, + "proto3Optional": false, + }, { + "name": "aggregate_value", + "number": 8, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "aggregateValue", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [{ + "name": "NamePart", + "field": [{ + "name": "name_part", + "number": 1, + "label": 2, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "namePart", + "options": undefined, + "proto3Optional": false, + }, { + "name": "is_extension", + "number": 2, + "label": 2, + "type": 8, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "isExtension", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "SourceCodeInfo", + "field": [{ + "name": "location", + "number": 1, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.SourceCodeInfo.Location", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "location", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [{ + "name": "Location", + "field": [{ + "name": "path", + "number": 1, + "label": 3, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "path", + "options": { + "ctype": 0, + "packed": true, + "jstype": 0, + "lazy": false, + "deprecated": false, + "weak": false, + "uninterpretedOption": [], }, - ], - extension: [], - nestedType: [ - { - name: 'NamePart', - field: [ - { - name: 'name_part', - number: 1, - label: 2, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'namePart', - options: undefined, - proto3Optional: false, - }, - { - name: 'is_extension', - number: 2, - label: 2, - type: 8, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'isExtension', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], + "proto3Optional": false, + }, { + "name": "span", + "number": 2, + "label": 3, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "span", + "options": { + "ctype": 0, + "packed": true, + "jstype": 0, + "lazy": false, + "deprecated": false, + "weak": false, + "uninterpretedOption": [], }, - ], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'SourceCodeInfo', - field: [ - { - name: 'location', - number: 1, - label: 3, - type: 11, - typeName: '.google.protobuf.SourceCodeInfo.Location', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'location', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [ - { - name: 'Location', - field: [ - { - name: 'path', - number: 1, - label: 3, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'path', - options: { - ctype: 0, - packed: true, - jstype: 0, - lazy: false, - deprecated: false, - weak: false, - uninterpretedOption: [], - }, - proto3Optional: false, - }, - { - name: 'span', - number: 2, - label: 3, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'span', - options: { - ctype: 0, - packed: true, - jstype: 0, - lazy: false, - deprecated: false, - weak: false, - uninterpretedOption: [], - }, - proto3Optional: false, - }, - { - name: 'leading_comments', - number: 3, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'leadingComments', - options: undefined, - proto3Optional: false, - }, - { - name: 'trailing_comments', - number: 4, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'trailingComments', - options: undefined, - proto3Optional: false, - }, - { - name: 'leading_detached_comments', - number: 6, - label: 3, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'leadingDetachedComments', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], + "proto3Optional": false, + }, { + "name": "leading_comments", + "number": 3, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "leadingComments", + "options": undefined, + "proto3Optional": false, + }, { + "name": "trailing_comments", + "number": 4, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "trailingComments", + "options": undefined, + "proto3Optional": false, + }, { + "name": "leading_detached_comments", + "number": 6, + "label": 3, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "leadingDetachedComments", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "GeneratedCodeInfo", + "field": [{ + "name": "annotation", + "number": 1, + "label": 3, + "type": 11, + "typeName": ".google.protobuf.GeneratedCodeInfo.Annotation", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "annotation", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [{ + "name": "Annotation", + "field": [{ + "name": "path", + "number": 1, + "label": 3, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "path", + "options": { + "ctype": 0, + "packed": true, + "jstype": 0, + "lazy": false, + "deprecated": false, + "weak": false, + "uninterpretedOption": [], }, + "proto3Optional": false, + }, { + "name": "source_file", + "number": 2, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "sourceFile", + "options": undefined, + "proto3Optional": false, + }, { + "name": "begin", + "number": 3, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "begin", + "options": undefined, + "proto3Optional": false, + }, { + "name": "end", + "number": 4, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "end", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "service": [], + "extension": [], + "options": { + "javaPackage": "com.google.protobuf", + "javaOuterClassname": "DescriptorProtos", + "javaMultipleFiles": false, + "javaGenerateEqualsAndHash": false, + "javaStringCheckUtf8": false, + "optimizeFor": 1, + "goPackage": "google.golang.org/protobuf/types/descriptorpb", + "ccGenericServices": false, + "javaGenericServices": false, + "pyGenericServices": false, + "phpGenericServices": false, + "deprecated": false, + "ccEnableArenas": true, + "objcClassPrefix": "GPB", + "csharpNamespace": "Google.Protobuf.Reflection", + "swiftPrefix": "", + "phpClassPrefix": "", + "phpNamespace": "", + "phpMetadataNamespace": "", + "rubyPackage": "", + "uninterpretedOption": [], + }, + "sourceCodeInfo": { + "location": [{ + "path": [8, 9], + "span": [52, 0, 28], + "leadingComments": + " descriptor.proto must be optimized for speed because reflection-based\n algorithms don't work during bootstrapping.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 0], + "span": [56, 0, 58, 1], + "leadingComments": + " The protocol compiler can output a FileDescriptorSet containing the .proto\n files it parses.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 1], + "span": [61, 0, 90, 1], + "leadingComments": " Describes a complete .proto file.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 1, 2, 0], + "span": [62, 2, 27], + "leadingComments": "", + "trailingComments": " file name, relative to root of source tree\n", + "leadingDetachedComments": [], + }, { + "path": [4, 1, 2, 1], + "span": [63, 2, 30], + "leadingComments": "", + "trailingComments": ' e.g. "foo", "foo.bar", etc.\n', + "leadingDetachedComments": [], + }, { + "path": [4, 1, 2, 2], + "span": [66, 2, 33], + "leadingComments": " Names of files imported by this file.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 1, 2, 3], + "span": [68, 2, 40], + "leadingComments": " Indexes of the public imported files in the dependency list above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 1, 2, 4], + "span": [71, 2, 38], + "leadingComments": + " Indexes of the weak imported files in the dependency list.\n For Google-internal migration only. Do not use.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 1, 2, 5], + "span": [74, 2, 44], + "leadingComments": " All top-level definitions in this file.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 1, 2, 10], + "span": [85, 2, 47], + "leadingComments": + " This field contains optional information about the original source code.\n You may safely remove this entire field without harming runtime\n functionality of the descriptors -- the information is needed only by\n development tools.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 1, 2, 11], + "span": [89, 2, 30], + "leadingComments": ' The syntax of the proto file.\n The supported values are "proto2" and "proto3".\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 2], + "span": [93, 0, 125, 1], + "leadingComments": " Describes a message type.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 2, 3, 0, 2, 0], + "span": [103, 4, 29], + "leadingComments": "", + "trailingComments": " Inclusive.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 2, 3, 0, 2, 1], + "span": [104, 4, 27], + "leadingComments": "", + "trailingComments": " Exclusive.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 2, 3, 1], + "span": [117, 2, 120, 3], + "leadingComments": + " Range of reserved tag numbers. Reserved tag numbers may not be used by\n fields or extension ranges in the same message. Reserved ranges may\n not overlap.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 2, 3, 1, 2, 0], + "span": [118, 4, 29], + "leadingComments": "", + "trailingComments": " Inclusive.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 2, 3, 1, 2, 1], + "span": [119, 4, 27], + "leadingComments": "", + "trailingComments": " Exclusive.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 2, 2, 9], + "span": [124, 2, 37], + "leadingComments": + " Reserved field names, which may not be used by fields in the same message.\n A given name may only be reserved once.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 3, 2, 0], + "span": [129, 2, 58], + "leadingComments": " The parser stores options it doesn't recognize here. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 3, 5], + "span": [133, 2, 25], + "leadingComments": " Clients can define custom options in extensions of this message. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4], + "span": [137, 0, 238, 1], + "leadingComments": " Describes a field within a message.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 4, 0, 2, 0], + "span": [141, 4, 20], + "leadingComments": " 0 is reserved for errors.\n Order is weird for historical reasons.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 4, 0, 2, 2], + "span": [145, 4, 19], + "leadingComments": + " Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if\n negative values are likely.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 4, 0, 2, 4], + "span": [149, 4, 19], + "leadingComments": + " Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if\n negative values are likely.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 4, 0, 2, 9], + "span": [158, 4, 20], + "leadingComments": + " Tag-delimited aggregate.\n Group type is deprecated and not supported in proto3. However, Proto3\n implementations should still be able to parse the group wire format and\n treat group fields as unknown fields.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 4, 0, 2, 10], + "span": [159, 4, 22], + "leadingComments": "", + "trailingComments": " Length-delimited aggregate.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 4, 0, 2, 11], + "span": [162, 4, 20], + "leadingComments": " New in version 2.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 4, 0, 2, 16], + "span": [167, 4, 21], + "leadingComments": "", + "trailingComments": " Uses ZigZag encoding.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 4, 0, 2, 17], + "span": [168, 4, 21], + "leadingComments": "", + "trailingComments": " Uses ZigZag encoding.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 4, 1, 2, 0], + "span": [173, 4, 23], + "leadingComments": " 0 is reserved for errors\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 2, 3], + "span": [184, 2, 25], + "leadingComments": + " If type_name is set, this need not be set. If both this and type_name\n are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 2, 4], + "span": [191, 2, 32], + "leadingComments": + " For message and enum types, this is the name of the type. If the name\n starts with a '.', it is fully-qualified. Otherwise, C++-like scoping\n rules are used to find the type (i.e. first the nested types within this\n message are searched, then within the parent, on up to the root\n namespace).\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 2, 5], + "span": [195, 2, 31], + "leadingComments": + " For extensions, this is the name of the type being extended. It is\n resolved in the same manner as type_name.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 2, 6], + "span": [202, 2, 36], + "leadingComments": + ' For numeric types, contains the original text representation of the value.\n For booleans, "true" or "false".\n For strings, contains the default text contents (not escaped in any way).\n For bytes, contains the C escaped value. All bytes >= 128 are escaped.\n TODO(kenton): Base-64 encode?\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 2, 7], + "span": [206, 2, 33], + "leadingComments": + " If set, gives the index of a oneof in the containing type's oneof_decl\n list. This field is a member of that oneof.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 2, 8], + "span": [212, 2, 33], + "leadingComments": + " JSON name of this field. The value is set by protocol compiler. If the\n user has set a \"json_name\" option on this field, that option's value\n will be used. Otherwise, it's deduced from the field's name by converting\n it to camelCase.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 4, 2, 10], + "span": [237, 2, 37], + "leadingComments": + ' If true, this is a proto3 "optional". When a proto3 field is optional, it\n tracks presence regardless of field type.\n\n When proto3_optional is true, this field must be belong to a oneof to\n signal to old proto3 clients that presence is tracked for this field. This\n oneof is known as a "synthetic" oneof, and this field must be its sole\n member (each proto3 optional field gets its own synthetic oneof). Synthetic\n oneofs exist in the descriptor only, and do not generate any API. Synthetic\n oneofs must be ordered after all "real" oneofs.\n\n For message fields, proto3_optional doesn\'t create any semantic change,\n since non-repeated message fields always track presence. However it still\n indicates the semantic detail of whether the user wrote "optional" or not.\n This can be useful for round-tripping the .proto file. For consistency we\n give message fields a synthetic oneof also, even though it is not required\n to track presence. This is especially important because the parser can\'t\n tell if a field is a message or an enum, so it must always create a\n synthetic oneof.\n\n Proto2 optional fields do not set this flag, because they already indicate\n optional with `LABEL_OPTIONAL`.\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 5], + "span": [241, 0, 244, 1], + "leadingComments": " Describes a oneof.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 6], + "span": [247, 0, 273, 1], + "leadingComments": " Describes an enum type.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 6, 3, 0], + "span": [260, 2, 263, 3], + "leadingComments": + " Range of reserved numeric values. Reserved values may not be used by\n entries in the same enum. Reserved ranges may not overlap.\n\n Note that this is distinct from DescriptorProto.ReservedRange in that it\n is inclusive such that it can appropriately represent the entire int32\n domain.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 6, 3, 0, 2, 0], + "span": [261, 4, 29], + "leadingComments": "", + "trailingComments": " Inclusive.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 6, 3, 0, 2, 1], + "span": [262, 4, 27], + "leadingComments": "", + "trailingComments": " Inclusive.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 6, 2, 3], + "span": [268, 2, 48], + "leadingComments": + " Range of reserved numeric values. Reserved numeric values may not be used\n by enum values in the same enum declaration. Reserved ranges may not\n overlap.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 6, 2, 4], + "span": [272, 2, 36], + "leadingComments": + " Reserved enum value names, which may not be reused. A given name may only\n be reserved once.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 7], + "span": [276, 0, 281, 1], + "leadingComments": " Describes a value within an enum.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 8], + "span": [284, 0, 289, 1], + "leadingComments": " Describes a service.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 9], + "span": [292, 0, 306, 1], + "leadingComments": " Describes a method of a service.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 9, 2, 1], + "span": [297, 2, 33], + "leadingComments": + " Input and output type names. These are resolved in the same way as\n FieldDescriptorProto.type_name, but must refer to a message type.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 9, 2, 4], + "span": [303, 2, 55], + "leadingComments": " Identifies if client streams multiple client messages\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 9, 2, 5], + "span": [305, 2, 55], + "leadingComments": " Identifies if server streams multiple server messages\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 0], + "span": [347, 2, 35], + "leadingComments": + " Sets the Java package where classes generated from this .proto will be\n placed. By default, the proto package is used, but this is often\n inappropriate because proto packages do not normally start with backwards\n domain names.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 1], + "span": [355, 2, 43], + "leadingComments": + " Controls the name of the wrapper Java class generated for the .proto file.\n That class will always contain the .proto file's getDescriptor() method as\n well as any top-level extensions defined in the .proto file.\n If java_multiple_files is disabled, then all the other classes from the\n .proto file will be nested inside the single wrapper outer class.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 2], + "span": [363, 2, 59], + "leadingComments": + " If enabled, then the Java code generator will generate a separate .java\n file for each top-level message, enum, and service defined in the .proto\n file. Thus, these types will *not* be nested inside the wrapper class\n named by java_outer_classname. However, the wrapper class will still be\n generated to contain the file's getDescriptor() method as well as any\n top-level extensions defined in the file.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 3], + "span": [366, 2, 69], + "leadingComments": " This option does nothing.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 4], + "span": [374, 2, 62], + "leadingComments": + " If set true, then the Java2 code generator will generate code that\n throws an exception whenever an attempt is made to assign a non-UTF-8\n byte sequence to a string field.\n Message reflection will do the same.\n However, an extension field still accepts non-UTF-8 byte sequences.\n This option has no effect on when used with the lite runtime.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 4, 0], + "span": [378, 2, 383, 3], + "leadingComments": " Generated classes can be optimized for speed or code size.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 4, 0, 2, 0], + "span": [379, 4, 14], + "leadingComments": "", + "trailingComments": " Generate complete code for parsing, serialization,\n", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 4, 0, 2, 1], + "span": [381, 4, 18], + "leadingComments": " etc.\n", + "trailingComments": " Use ReflectionOps to implement these methods.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 4, 0, 2, 2], + "span": [382, 4, 21], + "leadingComments": "", + "trailingComments": " Generate code using MessageLite and the lite runtime.\n", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 6], + "span": [391, 2, 34], + "leadingComments": + " Sets the Go package where structs generated from this .proto will be\n placed. If omitted, the Go package will be derived from the following:\n - The basename of the package import path, if provided.\n - Otherwise, the package statement in the .proto file, if present.\n - Otherwise, the basename of the .proto file, without extension.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 7], + "span": [406, 2, 59], + "leadingComments": + ' Should generic services be generated in each language? "Generic" services\n are not specific to any particular RPC system. They are generated by the\n main code generators in each language (without additional plugins).\n Generic services were the only kind of service generation supported by\n early versions of google.protobuf.\n\n Generic services are now considered deprecated in favor of using plugins\n that generate code specific to your particular RPC system. Therefore,\n these default to false. Old code which depends on generic services should\n explicitly set them to true.\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 11], + "span": [415, 2, 50], + "leadingComments": + " Is this file deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for everything in the file, or it will be completely ignored; in the very\n least, this is a formalization for deprecating files.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 12], + "span": [419, 2, 55], + "leadingComments": + " Enables the use of arenas for the proto messages in this file. This applies\n only to generated classes for C++.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 13], + "span": [424, 2, 41], + "leadingComments": + " Sets the objective c class prefix which is prepended to all objective c\n generated classes from this .proto. There is no default.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 14], + "span": [427, 2, 40], + "leadingComments": " Namespace for generated classes; defaults to the package.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 15], + "span": [433, 2, 36], + "leadingComments": + " By default Swift generators will take the proto package and CamelCase it\n replacing '.' with underscore and use that to prefix the types/symbols\n defined. When this options is provided, they will use this value instead\n to prefix the types/symbols defined.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 16], + "span": [437, 2, 40], + "leadingComments": + " Sets the php class prefix which is prepended to all php generated classes\n from this .proto. Default is empty.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 17], + "span": [442, 2, 37], + "leadingComments": + " Use this option to change the namespace of php generated classes. Default\n is empty. When this option is empty, the package name will be used for\n determining the namespace.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 18], + "span": [447, 2, 46], + "leadingComments": + " Use this option to change the namespace of php generated metadata classes.\n Default is empty. When this option is empty, the proto file name will be\n used for determining the namespace.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 19], + "span": [452, 2, 36], + "leadingComments": + " Use this option to change the package of ruby generated classes. Default\n is empty. When this option is not set, the package name will be used for\n determining the ruby package.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 2, 20], + "span": [457, 2, 58], + "leadingComments": + ' The parser stores options it doesn\'t recognize here.\n See the documentation for the "Options" section above.\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 10, 5], + "span": [461, 2, 25], + "leadingComments": + ' Clients can define custom options in extensions of this message.\n See the documentation for the "Options" section above.\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 11, 2, 0], + "span": [485, 2, 62], + "leadingComments": + " Set true to use the old proto1 MessageSet wire format for extensions.\n This is provided for backwards-compatibility with the MessageSet wire\n format. You should not use this for any other reason: It's less\n efficient, has fewer features, and is more complicated.\n\n The message must be defined exactly as follows:\n message Foo {\n option message_set_wire_format = true;\n extensions 4 to max;\n }\n Note that the message cannot have any defined fields; MessageSets only\n have extensions.\n\n All extensions of your type must be singular messages; e.g. they cannot\n be int32s, enums, or repeated messages.\n\n Because this is an option, the above two restrictions are not enforced by\n the protocol compiler.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 11, 2, 1], + "span": [490, 2, 70], + "leadingComments": + ' Disables the generation of the standard "descriptor()" accessor, which can\n conflict with a field of the same name. This is meant to make migration\n from proto1 easier; new code should avoid fields named "descriptor".\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 11, 2, 2], + "span": [496, 2, 49], + "leadingComments": + " Is this message deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for the message, or it will be completely ignored; in the very least,\n this is a formalization for deprecating messages.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 11, 2, 3], + "span": [521, 2, 30], + "leadingComments": + " Whether the message is an automatically generated map entry type for the\n maps field.\n\n For maps fields:\n map map_field = 1;\n The parsed descriptor looks like:\n message MapFieldEntry {\n option map_entry = true;\n optional KeyType key = 1;\n optional ValueType value = 2;\n }\n repeated MapFieldEntry map_field = 1;\n\n Implementations may choose not to generate the map_entry=true message, but\n use a native map in the target language to hold the keys and values.\n The reflection APIs in such implementations still need to work as\n if the field is a repeated message field.\n\n NOTE: Do not set the option in .proto files. Always use the maps syntax\n instead. The option should only be implicitly set by the proto compiler\n parser.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 11, 9], + "span": [523, 2, 13], + "leadingComments": "", + "trailingComments": " javalite_serializable\n", + "leadingDetachedComments": [], + }, { + "path": [4, 11, 9], + "span": [524, 2, 13], + "leadingComments": "", + "trailingComments": " javanano_as_lite\n", + "leadingDetachedComments": [], + }, { + "path": [4, 11, 2, 4], + "span": [528, 2, 58], + "leadingComments": " The parser stores options it doesn't recognize here. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 11, 5], + "span": [531, 2, 25], + "leadingComments": " Clients can define custom options in extensions of this message. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 0], + "span": [539, 2, 46], + "leadingComments": + " The ctype option instructs the C++ code generator to use a different\n representation of the field than it normally would. See the specific\n options below. This option is not yet implemented in the open source\n release -- sorry, we'll try to include it in a future version!\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 4, 0, 2, 0], + "span": [542, 4, 15], + "leadingComments": " Default mode.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 1], + "span": [553, 2, 27], + "leadingComments": + " The packed option can be enabled for repeated primitive fields to enable\n a more efficient representation on the wire. Rather than repeatedly\n writing the tag and type for each element, the entire array is encoded as\n a single length-delimited blob. In proto3, only explicit setting it to\n false will avoid using packed encoding.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 2], + "span": [566, 2, 51], + "leadingComments": + ' The jstype option determines the JavaScript type used for values of the\n field. The option is permitted only for 64 bit integral and fixed types\n (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING\n is represented as JavaScript string, which avoids loss of precision that\n can happen when a large value is converted to a floating point JavaScript.\n Specifying JS_NUMBER for the jstype causes the generated JavaScript code to\n use the JavaScript "number" type. The behavior of the default option\n JS_NORMAL is implementation dependent.\n\n This option is an enum to permit additional types to be added, e.g.\n goog.math.Integer.\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 4, 1, 2, 0], + "span": [569, 4, 18], + "leadingComments": " Use the default type.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 4, 1, 2, 1], + "span": [572, 4, 18], + "leadingComments": " Use JavaScript strings.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 4, 1, 2, 2], + "span": [575, 4, 18], + "leadingComments": " Use JavaScript numbers.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 3], + "span": [606, 2, 43], + "leadingComments": + " Should this field be parsed lazily? Lazy applies only to message-type\n fields. It means that when the outer message is initially parsed, the\n inner message's contents will not be parsed but instead stored in encoded\n form. The inner message will actually be parsed when it is first accessed.\n\n This is only a hint. Implementations are free to choose whether to use\n eager or lazy parsing regardless of the value of this option. However,\n setting this option true suggests that the protocol author believes that\n using lazy parsing on this field is worth the additional bookkeeping\n overhead typically needed to implement it.\n\n This option does not affect the public interface of any generated code;\n all method signatures remain the same. Furthermore, thread-safety of the\n interface is not affected by this option; const methods remain safe to\n call from multiple threads concurrently, while non-const methods continue\n to require exclusive access.\n\n\n Note that implementations may choose not to check required fields within\n a lazy sub-message. That is, calling IsInitialized() on the outer message\n may return true even if the inner message has missing required fields.\n This is necessary because otherwise the inner message would have to be\n parsed in order to perform the check, defeating the purpose of lazy\n parsing. An implementation which chooses not to check required fields\n must be consistent about it. That is, for any particular sub-message, the\n implementation must either *always* check its required fields, or *never*\n check its required fields, regardless of whether or not the message has\n been parsed.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 4], + "span": [612, 2, 49], + "leadingComments": + " Is this field deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for accessors, or it will be completely ignored; in the very least, this\n is a formalization for deprecating fields.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 5], + "span": [615, 2, 44], + "leadingComments": " For Google-internal migration only. Do not use.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 2, 6], + "span": [619, 2, 58], + "leadingComments": " The parser stores options it doesn't recognize here. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 5], + "span": [622, 2, 25], + "leadingComments": " Clients can define custom options in extensions of this message. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 12, 9], + "span": [624, 2, 13], + "leadingComments": "", + "trailingComments": " removed jtype\n", + "leadingDetachedComments": [], + }, { + "path": [4, 13, 2, 0], + "span": [629, 2, 58], + "leadingComments": " The parser stores options it doesn't recognize here. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 13, 5], + "span": [632, 2, 25], + "leadingComments": " Clients can define custom options in extensions of this message. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 14, 2, 0], + "span": [639, 2, 32], + "leadingComments": " Set this option to true to allow mapping different tag names to the same\n value.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 14, 2, 1], + "span": [645, 2, 49], + "leadingComments": + " Is this enum deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for the enum, or it will be completely ignored; in the very least, this\n is a formalization for deprecating enums.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 14, 9], + "span": [647, 2, 13], + "leadingComments": "", + "trailingComments": " javanano_as_lite\n", + "leadingDetachedComments": [], + }, { + "path": [4, 14, 2, 2], + "span": [650, 2, 58], + "leadingComments": " The parser stores options it doesn't recognize here. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 14, 5], + "span": [653, 2, 25], + "leadingComments": " Clients can define custom options in extensions of this message. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 15, 2, 0], + "span": [661, 2, 49], + "leadingComments": + " Is this enum value deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for the enum value, or it will be completely ignored; in the very least,\n this is a formalization for deprecating enum values.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 15, 2, 1], + "span": [664, 2, 58], + "leadingComments": " The parser stores options it doesn't recognize here. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 15, 5], + "span": [667, 2, 25], + "leadingComments": " Clients can define custom options in extensions of this message. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 16, 2, 0], + "span": [681, 2, 50], + "leadingComments": + " Is this service deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for the service, or it will be completely ignored; in the very least,\n this is a formalization for deprecating services.\n", + "trailingComments": "", + "leadingDetachedComments": [ + " Note: Field numbers 1 through 32 are reserved for Google's internal RPC\n framework. We apologize for hoarding these numbers to ourselves, but\n we were already using them long before we decided to release Protocol\n Buffers.\n", ], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'GeneratedCodeInfo', - field: [ - { - name: 'annotation', - number: 1, - label: 3, - type: 11, - typeName: '.google.protobuf.GeneratedCodeInfo.Annotation', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'annotation', - options: undefined, - proto3Optional: false, - }, + }, { + "path": [4, 16, 2, 1], + "span": [684, 2, 58], + "leadingComments": " The parser stores options it doesn't recognize here. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 16, 5], + "span": [687, 2, 25], + "leadingComments": " Clients can define custom options in extensions of this message. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 17, 2, 0], + "span": [701, 2, 50], + "leadingComments": + " Is this method deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for the method, or it will be completely ignored; in the very least,\n this is a formalization for deprecating methods.\n", + "trailingComments": "", + "leadingDetachedComments": [ + " Note: Field numbers 1 through 32 are reserved for Google's internal RPC\n framework. We apologize for hoarding these numbers to ourselves, but\n we were already using them long before we decided to release Protocol\n Buffers.\n", ], - extension: [], - nestedType: [ - { - name: 'Annotation', - field: [ - { - name: 'path', - number: 1, - label: 3, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'path', - options: { - ctype: 0, - packed: true, - jstype: 0, - lazy: false, - deprecated: false, - weak: false, - uninterpretedOption: [], - }, - proto3Optional: false, - }, - { - name: 'source_file', - number: 2, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'sourceFile', - options: undefined, - proto3Optional: false, - }, - { - name: 'begin', - number: 3, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'begin', - options: undefined, - proto3Optional: false, - }, - { - name: 'end', - number: 4, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'end', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, + }, { + "path": [4, 17, 4, 0], + "span": [706, 2, 710, 3], + "leadingComments": + " Is this method side-effect-free (or safe in HTTP parlance), or idempotent,\n or neither? HTTP based RPC implementation may choose GET verb for safe\n methods, and PUT verb for idempotent methods instead of the default POST.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 17, 4, 0, 2, 1], + "span": [708, 4, 24], + "leadingComments": "", + "trailingComments": " implies idempotent\n", + "leadingDetachedComments": [], + }, { + "path": [4, 17, 4, 0, 2, 2], + "span": [709, 4, 19], + "leadingComments": "", + "trailingComments": " idempotent, but may have side effects\n", + "leadingDetachedComments": [], + }, { + "path": [4, 17, 2, 2], + "span": [715, 2, 58], + "leadingComments": " The parser stores options it doesn't recognize here. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 17, 5], + "span": [718, 2, 25], + "leadingComments": " Clients can define custom options in extensions of this message. See above.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 18], + "span": [728, 0, 748, 1], + "leadingComments": + " A message representing a option the parser does not recognize. This only\n appears in options protos created by the compiler::Parser class.\n DescriptorPool resolves these when building Descriptor objects. Therefore,\n options protos in descriptor objects (e.g. returned by Descriptor::options(),\n or produced by Descriptor::CopyTo()) will never have UninterpretedOptions\n in them.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 18, 3, 0], + "span": [734, 2, 737, 3], + "leadingComments": + ' The name of the uninterpreted option. Each string represents a segment in\n a dot-separated name. is_extension is true iff a segment represents an\n extension (denoted with parentheses in options specs in .proto files).\n E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents\n "foo.(bar.baz).qux".\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 18, 2, 1], + "span": [742, 2, 39], + "leadingComments": + " The value of the uninterpreted option, in whatever type the tokenizer\n identified it as during parsing. Exactly one of these should be set.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 19], + "span": [755, 0, 884, 1], + "leadingComments": + " Encapsulates information about the original source file from which a\n FileDescriptorProto was generated.\n", + "trailingComments": "", + "leadingDetachedComments": [ + " ===================================================================\n Optional source code info\n", ], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - service: [], - extension: [], - options: { - javaPackage: 'com.google.protobuf', - javaOuterClassname: 'DescriptorProtos', - javaMultipleFiles: false, - javaGenerateEqualsAndHash: false, - javaStringCheckUtf8: false, - optimizeFor: 1, - goPackage: 'google.golang.org/protobuf/types/descriptorpb', - ccGenericServices: false, - javaGenericServices: false, - pyGenericServices: false, - phpGenericServices: false, - deprecated: false, - ccEnableArenas: true, - objcClassPrefix: 'GPB', - csharpNamespace: 'Google.Protobuf.Reflection', - swiftPrefix: '', - phpClassPrefix: '', - phpNamespace: '', - phpMetadataNamespace: '', - rubyPackage: '', - uninterpretedOption: [], - }, - sourceCodeInfo: { - location: [ - { - path: [8, 9], - span: [52, 0, 28], - leadingComments: - " descriptor.proto must be optimized for speed because reflection-based\n algorithms don't work during bootstrapping.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 0], - span: [56, 0, 58, 1], - leadingComments: - ' The protocol compiler can output a FileDescriptorSet containing the .proto\n files it parses.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 1], - span: [61, 0, 90, 1], - leadingComments: ' Describes a complete .proto file.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 1, 2, 0], - span: [62, 2, 27], - leadingComments: '', - trailingComments: ' file name, relative to root of source tree\n', - leadingDetachedComments: [], - }, - { - path: [4, 1, 2, 1], - span: [63, 2, 30], - leadingComments: '', - trailingComments: ' e.g. "foo", "foo.bar", etc.\n', - leadingDetachedComments: [], - }, - { - path: [4, 1, 2, 2], - span: [66, 2, 33], - leadingComments: ' Names of files imported by this file.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 1, 2, 3], - span: [68, 2, 40], - leadingComments: ' Indexes of the public imported files in the dependency list above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 1, 2, 4], - span: [71, 2, 38], - leadingComments: - ' Indexes of the weak imported files in the dependency list.\n For Google-internal migration only. Do not use.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 1, 2, 5], - span: [74, 2, 44], - leadingComments: ' All top-level definitions in this file.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 1, 2, 10], - span: [85, 2, 47], - leadingComments: - ' This field contains optional information about the original source code.\n You may safely remove this entire field without harming runtime\n functionality of the descriptors -- the information is needed only by\n development tools.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 1, 2, 11], - span: [89, 2, 30], - leadingComments: ' The syntax of the proto file.\n The supported values are "proto2" and "proto3".\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 2], - span: [93, 0, 125, 1], - leadingComments: ' Describes a message type.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 2, 3, 0, 2, 0], - span: [103, 4, 29], - leadingComments: '', - trailingComments: ' Inclusive.\n', - leadingDetachedComments: [], - }, - { - path: [4, 2, 3, 0, 2, 1], - span: [104, 4, 27], - leadingComments: '', - trailingComments: ' Exclusive.\n', - leadingDetachedComments: [], - }, - { - path: [4, 2, 3, 1], - span: [117, 2, 120, 3], - leadingComments: - ' Range of reserved tag numbers. Reserved tag numbers may not be used by\n fields or extension ranges in the same message. Reserved ranges may\n not overlap.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 2, 3, 1, 2, 0], - span: [118, 4, 29], - leadingComments: '', - trailingComments: ' Inclusive.\n', - leadingDetachedComments: [], - }, - { - path: [4, 2, 3, 1, 2, 1], - span: [119, 4, 27], - leadingComments: '', - trailingComments: ' Exclusive.\n', - leadingDetachedComments: [], - }, - { - path: [4, 2, 2, 9], - span: [124, 2, 37], - leadingComments: - ' Reserved field names, which may not be used by fields in the same message.\n A given name may only be reserved once.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 3, 2, 0], - span: [129, 2, 58], - leadingComments: " The parser stores options it doesn't recognize here. See above.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 3, 5], - span: [133, 2, 25], - leadingComments: ' Clients can define custom options in extensions of this message. See above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4], - span: [137, 0, 238, 1], - leadingComments: ' Describes a field within a message.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 4, 0, 2, 0], - span: [141, 4, 20], - leadingComments: ' 0 is reserved for errors.\n Order is weird for historical reasons.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 4, 0, 2, 2], - span: [145, 4, 19], - leadingComments: - ' Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if\n negative values are likely.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 4, 0, 2, 4], - span: [149, 4, 19], - leadingComments: - ' Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if\n negative values are likely.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 4, 0, 2, 9], - span: [158, 4, 20], - leadingComments: - ' Tag-delimited aggregate.\n Group type is deprecated and not supported in proto3. However, Proto3\n implementations should still be able to parse the group wire format and\n treat group fields as unknown fields.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 4, 0, 2, 10], - span: [159, 4, 22], - leadingComments: '', - trailingComments: ' Length-delimited aggregate.\n', - leadingDetachedComments: [], - }, - { - path: [4, 4, 4, 0, 2, 11], - span: [162, 4, 20], - leadingComments: ' New in version 2.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 4, 0, 2, 16], - span: [167, 4, 21], - leadingComments: '', - trailingComments: ' Uses ZigZag encoding.\n', - leadingDetachedComments: [], - }, - { - path: [4, 4, 4, 0, 2, 17], - span: [168, 4, 21], - leadingComments: '', - trailingComments: ' Uses ZigZag encoding.\n', - leadingDetachedComments: [], - }, - { - path: [4, 4, 4, 1, 2, 0], - span: [173, 4, 23], - leadingComments: ' 0 is reserved for errors\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 2, 3], - span: [184, 2, 25], - leadingComments: - ' If type_name is set, this need not be set. If both this and type_name\n are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 2, 4], - span: [191, 2, 32], - leadingComments: - " For message and enum types, this is the name of the type. If the name\n starts with a '.', it is fully-qualified. Otherwise, C++-like scoping\n rules are used to find the type (i.e. first the nested types within this\n message are searched, then within the parent, on up to the root\n namespace).\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 2, 5], - span: [195, 2, 31], - leadingComments: - ' For extensions, this is the name of the type being extended. It is\n resolved in the same manner as type_name.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 2, 6], - span: [202, 2, 36], - leadingComments: - ' For numeric types, contains the original text representation of the value.\n For booleans, "true" or "false".\n For strings, contains the default text contents (not escaped in any way).\n For bytes, contains the C escaped value. All bytes >= 128 are escaped.\n TODO(kenton): Base-64 encode?\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 2, 7], - span: [206, 2, 33], - leadingComments: - " If set, gives the index of a oneof in the containing type's oneof_decl\n list. This field is a member of that oneof.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 2, 8], - span: [212, 2, 33], - leadingComments: - " JSON name of this field. The value is set by protocol compiler. If the\n user has set a \"json_name\" option on this field, that option's value\n will be used. Otherwise, it's deduced from the field's name by converting\n it to camelCase.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 4, 2, 10], - span: [237, 2, 37], - leadingComments: - ' If true, this is a proto3 "optional". When a proto3 field is optional, it\n tracks presence regardless of field type.\n\n When proto3_optional is true, this field must be belong to a oneof to\n signal to old proto3 clients that presence is tracked for this field. This\n oneof is known as a "synthetic" oneof, and this field must be its sole\n member (each proto3 optional field gets its own synthetic oneof). Synthetic\n oneofs exist in the descriptor only, and do not generate any API. Synthetic\n oneofs must be ordered after all "real" oneofs.\n\n For message fields, proto3_optional doesn\'t create any semantic change,\n since non-repeated message fields always track presence. However it still\n indicates the semantic detail of whether the user wrote "optional" or not.\n This can be useful for round-tripping the .proto file. For consistency we\n give message fields a synthetic oneof also, even though it is not required\n to track presence. This is especially important because the parser can\'t\n tell if a field is a message or an enum, so it must always create a\n synthetic oneof.\n\n Proto2 optional fields do not set this flag, because they already indicate\n optional with `LABEL_OPTIONAL`.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 5], - span: [241, 0, 244, 1], - leadingComments: ' Describes a oneof.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 6], - span: [247, 0, 273, 1], - leadingComments: ' Describes an enum type.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 6, 3, 0], - span: [260, 2, 263, 3], - leadingComments: - ' Range of reserved numeric values. Reserved values may not be used by\n entries in the same enum. Reserved ranges may not overlap.\n\n Note that this is distinct from DescriptorProto.ReservedRange in that it\n is inclusive such that it can appropriately represent the entire int32\n domain.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 6, 3, 0, 2, 0], - span: [261, 4, 29], - leadingComments: '', - trailingComments: ' Inclusive.\n', - leadingDetachedComments: [], - }, - { - path: [4, 6, 3, 0, 2, 1], - span: [262, 4, 27], - leadingComments: '', - trailingComments: ' Inclusive.\n', - leadingDetachedComments: [], - }, - { - path: [4, 6, 2, 3], - span: [268, 2, 48], - leadingComments: - ' Range of reserved numeric values. Reserved numeric values may not be used\n by enum values in the same enum declaration. Reserved ranges may not\n overlap.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 6, 2, 4], - span: [272, 2, 36], - leadingComments: - ' Reserved enum value names, which may not be reused. A given name may only\n be reserved once.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 7], - span: [276, 0, 281, 1], - leadingComments: ' Describes a value within an enum.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 8], - span: [284, 0, 289, 1], - leadingComments: ' Describes a service.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 9], - span: [292, 0, 306, 1], - leadingComments: ' Describes a method of a service.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 9, 2, 1], - span: [297, 2, 33], - leadingComments: - ' Input and output type names. These are resolved in the same way as\n FieldDescriptorProto.type_name, but must refer to a message type.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 9, 2, 4], - span: [303, 2, 55], - leadingComments: ' Identifies if client streams multiple client messages\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 9, 2, 5], - span: [305, 2, 55], - leadingComments: ' Identifies if server streams multiple server messages\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 0], - span: [347, 2, 35], - leadingComments: - ' Sets the Java package where classes generated from this .proto will be\n placed. By default, the proto package is used, but this is often\n inappropriate because proto packages do not normally start with backwards\n domain names.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 1], - span: [355, 2, 43], - leadingComments: - " Controls the name of the wrapper Java class generated for the .proto file.\n That class will always contain the .proto file's getDescriptor() method as\n well as any top-level extensions defined in the .proto file.\n If java_multiple_files is disabled, then all the other classes from the\n .proto file will be nested inside the single wrapper outer class.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 2], - span: [363, 2, 59], - leadingComments: - " If enabled, then the Java code generator will generate a separate .java\n file for each top-level message, enum, and service defined in the .proto\n file. Thus, these types will *not* be nested inside the wrapper class\n named by java_outer_classname. However, the wrapper class will still be\n generated to contain the file's getDescriptor() method as well as any\n top-level extensions defined in the file.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 3], - span: [366, 2, 69], - leadingComments: ' This option does nothing.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 4], - span: [374, 2, 62], - leadingComments: - ' If set true, then the Java2 code generator will generate code that\n throws an exception whenever an attempt is made to assign a non-UTF-8\n byte sequence to a string field.\n Message reflection will do the same.\n However, an extension field still accepts non-UTF-8 byte sequences.\n This option has no effect on when used with the lite runtime.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 4, 0], - span: [378, 2, 383, 3], - leadingComments: ' Generated classes can be optimized for speed or code size.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 4, 0, 2, 0], - span: [379, 4, 14], - leadingComments: '', - trailingComments: ' Generate complete code for parsing, serialization,\n', - leadingDetachedComments: [], - }, - { - path: [4, 10, 4, 0, 2, 1], - span: [381, 4, 18], - leadingComments: ' etc.\n', - trailingComments: ' Use ReflectionOps to implement these methods.\n', - leadingDetachedComments: [], - }, - { - path: [4, 10, 4, 0, 2, 2], - span: [382, 4, 21], - leadingComments: '', - trailingComments: ' Generate code using MessageLite and the lite runtime.\n', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 6], - span: [391, 2, 34], - leadingComments: - ' Sets the Go package where structs generated from this .proto will be\n placed. If omitted, the Go package will be derived from the following:\n - The basename of the package import path, if provided.\n - Otherwise, the package statement in the .proto file, if present.\n - Otherwise, the basename of the .proto file, without extension.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 7], - span: [406, 2, 59], - leadingComments: - ' Should generic services be generated in each language? "Generic" services\n are not specific to any particular RPC system. They are generated by the\n main code generators in each language (without additional plugins).\n Generic services were the only kind of service generation supported by\n early versions of google.protobuf.\n\n Generic services are now considered deprecated in favor of using plugins\n that generate code specific to your particular RPC system. Therefore,\n these default to false. Old code which depends on generic services should\n explicitly set them to true.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 11], - span: [415, 2, 50], - leadingComments: - ' Is this file deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for everything in the file, or it will be completely ignored; in the very\n least, this is a formalization for deprecating files.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 12], - span: [419, 2, 55], - leadingComments: - ' Enables the use of arenas for the proto messages in this file. This applies\n only to generated classes for C++.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 13], - span: [424, 2, 41], - leadingComments: - ' Sets the objective c class prefix which is prepended to all objective c\n generated classes from this .proto. There is no default.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 14], - span: [427, 2, 40], - leadingComments: ' Namespace for generated classes; defaults to the package.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 15], - span: [433, 2, 36], - leadingComments: - " By default Swift generators will take the proto package and CamelCase it\n replacing '.' with underscore and use that to prefix the types/symbols\n defined. When this options is provided, they will use this value instead\n to prefix the types/symbols defined.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 16], - span: [437, 2, 40], - leadingComments: - ' Sets the php class prefix which is prepended to all php generated classes\n from this .proto. Default is empty.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 17], - span: [442, 2, 37], - leadingComments: - ' Use this option to change the namespace of php generated classes. Default\n is empty. When this option is empty, the package name will be used for\n determining the namespace.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 18], - span: [447, 2, 46], - leadingComments: - ' Use this option to change the namespace of php generated metadata classes.\n Default is empty. When this option is empty, the proto file name will be\n used for determining the namespace.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 19], - span: [452, 2, 36], - leadingComments: - ' Use this option to change the package of ruby generated classes. Default\n is empty. When this option is not set, the package name will be used for\n determining the ruby package.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 2, 20], - span: [457, 2, 58], - leadingComments: - ' The parser stores options it doesn\'t recognize here.\n See the documentation for the "Options" section above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 10, 5], - span: [461, 2, 25], - leadingComments: - ' Clients can define custom options in extensions of this message.\n See the documentation for the "Options" section above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 11, 2, 0], - span: [485, 2, 62], - leadingComments: - " Set true to use the old proto1 MessageSet wire format for extensions.\n This is provided for backwards-compatibility with the MessageSet wire\n format. You should not use this for any other reason: It's less\n efficient, has fewer features, and is more complicated.\n\n The message must be defined exactly as follows:\n message Foo {\n option message_set_wire_format = true;\n extensions 4 to max;\n }\n Note that the message cannot have any defined fields; MessageSets only\n have extensions.\n\n All extensions of your type must be singular messages; e.g. they cannot\n be int32s, enums, or repeated messages.\n\n Because this is an option, the above two restrictions are not enforced by\n the protocol compiler.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 11, 2, 1], - span: [490, 2, 70], - leadingComments: - ' Disables the generation of the standard "descriptor()" accessor, which can\n conflict with a field of the same name. This is meant to make migration\n from proto1 easier; new code should avoid fields named "descriptor".\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 11, 2, 2], - span: [496, 2, 49], - leadingComments: - ' Is this message deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for the message, or it will be completely ignored; in the very least,\n this is a formalization for deprecating messages.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 11, 2, 3], - span: [521, 2, 30], - leadingComments: - ' Whether the message is an automatically generated map entry type for the\n maps field.\n\n For maps fields:\n map map_field = 1;\n The parsed descriptor looks like:\n message MapFieldEntry {\n option map_entry = true;\n optional KeyType key = 1;\n optional ValueType value = 2;\n }\n repeated MapFieldEntry map_field = 1;\n\n Implementations may choose not to generate the map_entry=true message, but\n use a native map in the target language to hold the keys and values.\n The reflection APIs in such implementations still need to work as\n if the field is a repeated message field.\n\n NOTE: Do not set the option in .proto files. Always use the maps syntax\n instead. The option should only be implicitly set by the proto compiler\n parser.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 11, 9], - span: [523, 2, 13], - leadingComments: '', - trailingComments: ' javalite_serializable\n', - leadingDetachedComments: [], - }, - { - path: [4, 11, 9], - span: [524, 2, 13], - leadingComments: '', - trailingComments: ' javanano_as_lite\n', - leadingDetachedComments: [], - }, - { - path: [4, 11, 2, 4], - span: [528, 2, 58], - leadingComments: " The parser stores options it doesn't recognize here. See above.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 11, 5], - span: [531, 2, 25], - leadingComments: ' Clients can define custom options in extensions of this message. See above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 0], - span: [539, 2, 46], - leadingComments: - " The ctype option instructs the C++ code generator to use a different\n representation of the field than it normally would. See the specific\n options below. This option is not yet implemented in the open source\n release -- sorry, we'll try to include it in a future version!\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 4, 0, 2, 0], - span: [542, 4, 15], - leadingComments: ' Default mode.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 1], - span: [553, 2, 27], - leadingComments: - ' The packed option can be enabled for repeated primitive fields to enable\n a more efficient representation on the wire. Rather than repeatedly\n writing the tag and type for each element, the entire array is encoded as\n a single length-delimited blob. In proto3, only explicit setting it to\n false will avoid using packed encoding.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 2], - span: [566, 2, 51], - leadingComments: - ' The jstype option determines the JavaScript type used for values of the\n field. The option is permitted only for 64 bit integral and fixed types\n (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING\n is represented as JavaScript string, which avoids loss of precision that\n can happen when a large value is converted to a floating point JavaScript.\n Specifying JS_NUMBER for the jstype causes the generated JavaScript code to\n use the JavaScript "number" type. The behavior of the default option\n JS_NORMAL is implementation dependent.\n\n This option is an enum to permit additional types to be added, e.g.\n goog.math.Integer.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 4, 1, 2, 0], - span: [569, 4, 18], - leadingComments: ' Use the default type.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 4, 1, 2, 1], - span: [572, 4, 18], - leadingComments: ' Use JavaScript strings.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 4, 1, 2, 2], - span: [575, 4, 18], - leadingComments: ' Use JavaScript numbers.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 3], - span: [606, 2, 43], - leadingComments: - " Should this field be parsed lazily? Lazy applies only to message-type\n fields. It means that when the outer message is initially parsed, the\n inner message's contents will not be parsed but instead stored in encoded\n form. The inner message will actually be parsed when it is first accessed.\n\n This is only a hint. Implementations are free to choose whether to use\n eager or lazy parsing regardless of the value of this option. However,\n setting this option true suggests that the protocol author believes that\n using lazy parsing on this field is worth the additional bookkeeping\n overhead typically needed to implement it.\n\n This option does not affect the public interface of any generated code;\n all method signatures remain the same. Furthermore, thread-safety of the\n interface is not affected by this option; const methods remain safe to\n call from multiple threads concurrently, while non-const methods continue\n to require exclusive access.\n\n\n Note that implementations may choose not to check required fields within\n a lazy sub-message. That is, calling IsInitialized() on the outer message\n may return true even if the inner message has missing required fields.\n This is necessary because otherwise the inner message would have to be\n parsed in order to perform the check, defeating the purpose of lazy\n parsing. An implementation which chooses not to check required fields\n must be consistent about it. That is, for any particular sub-message, the\n implementation must either *always* check its required fields, or *never*\n check its required fields, regardless of whether or not the message has\n been parsed.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 4], - span: [612, 2, 49], - leadingComments: - ' Is this field deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for accessors, or it will be completely ignored; in the very least, this\n is a formalization for deprecating fields.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 5], - span: [615, 2, 44], - leadingComments: ' For Google-internal migration only. Do not use.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 2, 6], - span: [619, 2, 58], - leadingComments: " The parser stores options it doesn't recognize here. See above.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 5], - span: [622, 2, 25], - leadingComments: ' Clients can define custom options in extensions of this message. See above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 12, 9], - span: [624, 2, 13], - leadingComments: '', - trailingComments: ' removed jtype\n', - leadingDetachedComments: [], - }, - { - path: [4, 13, 2, 0], - span: [629, 2, 58], - leadingComments: " The parser stores options it doesn't recognize here. See above.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 13, 5], - span: [632, 2, 25], - leadingComments: ' Clients can define custom options in extensions of this message. See above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 14, 2, 0], - span: [639, 2, 32], - leadingComments: ' Set this option to true to allow mapping different tag names to the same\n value.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 14, 2, 1], - span: [645, 2, 49], - leadingComments: - ' Is this enum deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for the enum, or it will be completely ignored; in the very least, this\n is a formalization for deprecating enums.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 14, 9], - span: [647, 2, 13], - leadingComments: '', - trailingComments: ' javanano_as_lite\n', - leadingDetachedComments: [], - }, - { - path: [4, 14, 2, 2], - span: [650, 2, 58], - leadingComments: " The parser stores options it doesn't recognize here. See above.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 14, 5], - span: [653, 2, 25], - leadingComments: ' Clients can define custom options in extensions of this message. See above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 15, 2, 0], - span: [661, 2, 49], - leadingComments: - ' Is this enum value deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for the enum value, or it will be completely ignored; in the very least,\n this is a formalization for deprecating enum values.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 15, 2, 1], - span: [664, 2, 58], - leadingComments: " The parser stores options it doesn't recognize here. See above.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 15, 5], - span: [667, 2, 25], - leadingComments: ' Clients can define custom options in extensions of this message. See above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 16, 2, 0], - span: [681, 2, 50], - leadingComments: - ' Is this service deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for the service, or it will be completely ignored; in the very least,\n this is a formalization for deprecating services.\n', - trailingComments: '', - leadingDetachedComments: [ - " Note: Field numbers 1 through 32 are reserved for Google's internal RPC\n framework. We apologize for hoarding these numbers to ourselves, but\n we were already using them long before we decided to release Protocol\n Buffers.\n", - ], - }, - { - path: [4, 16, 2, 1], - span: [684, 2, 58], - leadingComments: " The parser stores options it doesn't recognize here. See above.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 16, 5], - span: [687, 2, 25], - leadingComments: ' Clients can define custom options in extensions of this message. See above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 17, 2, 0], - span: [701, 2, 50], - leadingComments: - ' Is this method deprecated?\n Depending on the target platform, this can emit Deprecated annotations\n for the method, or it will be completely ignored; in the very least,\n this is a formalization for deprecating methods.\n', - trailingComments: '', - leadingDetachedComments: [ - " Note: Field numbers 1 through 32 are reserved for Google's internal RPC\n framework. We apologize for hoarding these numbers to ourselves, but\n we were already using them long before we decided to release Protocol\n Buffers.\n", - ], - }, - { - path: [4, 17, 4, 0], - span: [706, 2, 710, 3], - leadingComments: - ' Is this method side-effect-free (or safe in HTTP parlance), or idempotent,\n or neither? HTTP based RPC implementation may choose GET verb for safe\n methods, and PUT verb for idempotent methods instead of the default POST.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 17, 4, 0, 2, 1], - span: [708, 4, 24], - leadingComments: '', - trailingComments: ' implies idempotent\n', - leadingDetachedComments: [], - }, - { - path: [4, 17, 4, 0, 2, 2], - span: [709, 4, 19], - leadingComments: '', - trailingComments: ' idempotent, but may have side effects\n', - leadingDetachedComments: [], - }, - { - path: [4, 17, 2, 2], - span: [715, 2, 58], - leadingComments: " The parser stores options it doesn't recognize here. See above.\n", - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 17, 5], - span: [718, 2, 25], - leadingComments: ' Clients can define custom options in extensions of this message. See above.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 18], - span: [728, 0, 748, 1], - leadingComments: - ' A message representing a option the parser does not recognize. This only\n appears in options protos created by the compiler::Parser class.\n DescriptorPool resolves these when building Descriptor objects. Therefore,\n options protos in descriptor objects (e.g. returned by Descriptor::options(),\n or produced by Descriptor::CopyTo()) will never have UninterpretedOptions\n in them.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 18, 3, 0], - span: [734, 2, 737, 3], - leadingComments: - ' The name of the uninterpreted option. Each string represents a segment in\n a dot-separated name. is_extension is true iff a segment represents an\n extension (denoted with parentheses in options specs in .proto files).\n E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents\n "foo.(bar.baz).qux".\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 18, 2, 1], - span: [742, 2, 39], - leadingComments: - ' The value of the uninterpreted option, in whatever type the tokenizer\n identified it as during parsing. Exactly one of these should be set.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 19], - span: [755, 0, 884, 1], - leadingComments: - ' Encapsulates information about the original source file from which a\n FileDescriptorProto was generated.\n', - trailingComments: '', - leadingDetachedComments: [ - ' ===================================================================\n Optional source code info\n', - ], - }, - { - path: [4, 19, 2, 0], - span: [799, 2, 33], - leadingComments: - ' A Location identifies a piece of source code in a .proto file which\n corresponds to a particular definition. This information is intended\n to be useful to IDEs, code indexers, documentation generators, and similar\n tools.\n\n For example, say we have a file like:\n message Foo {\n optional string foo = 1;\n }\n Let\'s look at just the field definition:\n optional string foo = 1;\n ^ ^^ ^^ ^ ^^^\n a bc de f ghi\n We have the following locations:\n span path represents\n [a,i) [ 4, 0, 2, 0 ] The whole field definition.\n [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).\n [c,d) [ 4, 0, 2, 0, 5 ] The type (string).\n [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).\n [g,h) [ 4, 0, 2, 0, 3 ] The number (1).\n\n Notes:\n - A location may refer to a repeated field itself (i.e. not to any\n particular index within it). This is used whenever a set of elements are\n logically enclosed in a single code segment. For example, an entire\n extend block (possibly containing multiple extension definitions) will\n have an outer location whose path refers to the "extensions" repeated\n field without an index.\n - Multiple locations may have the same path. This happens when a single\n logical declaration is spread out across multiple places. The most\n obvious example is the "extend" block again -- there may be multiple\n extend blocks in the same scope, each of which will have the same path.\n - A location\'s span is not always a subset of its parent\'s span. For\n example, the "extendee" of an extension declaration appears at the\n beginning of the "extend" block and is shared by all extensions within\n the block.\n - Just because a location\'s span is a subset of some other location\'s span\n does not mean that it is a descendant. For example, a "group" defines\n both a type and a field in a single declaration. Thus, the locations\n corresponding to the type and field and their components will overlap.\n - Code which tries to interpret locations should probably be designed to\n ignore those that it doesn\'t understand, as more types of locations could\n be recorded in the future.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 19, 3, 0, 2, 0], - span: [824, 4, 44], - leadingComments: - ' Identifies which part of the FileDescriptorProto was defined at this\n location.\n\n Each element is a field number or an index. They form a path from\n the root FileDescriptorProto to the place where the definition. For\n example, this path:\n [ 4, 3, 2, 7, 1 ]\n refers to:\n file.message_type(3) // 4, 3\n .field(7) // 2, 7\n .name() // 1\n This is because FileDescriptorProto.message_type has field number 4:\n repeated DescriptorProto message_type = 4;\n and DescriptorProto.field has field number 2:\n repeated FieldDescriptorProto field = 2;\n and FieldDescriptorProto.name has field number 1:\n optional string name = 1;\n\n Thus, the above path gives the location of a field name. If we removed\n the last element:\n [ 4, 3, 2, 7 ]\n this path refers to the whole field declaration (from the beginning\n of the label to the terminating semicolon).\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 19, 3, 0, 2, 1], - span: [831, 4, 44], - leadingComments: - ' Always has exactly three or four elements: start line, start column,\n end line (optional, otherwise assumed same as start line), end column.\n These are packed into a single field for efficiency. Note that line\n and column numbers are zero-based -- typically you will want to add\n 1 to each before displaying to a user.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 19, 3, 0, 2, 2], - span: [880, 4, 41], - leadingComments: - ' If this SourceCodeInfo represents a complete declaration, these are any\n comments appearing before and after the declaration which appear to be\n attached to the declaration.\n\n A series of line comments appearing on consecutive lines, with no other\n tokens appearing on those lines, will be treated as a single comment.\n\n leading_detached_comments will keep paragraphs of comments that appear\n before (but not connected to) the current element. Each paragraph,\n separated by empty lines, will be one comment element in the repeated\n field.\n\n Only the comment content is provided; comment markers (e.g. //) are\n stripped out. For block comments, leading whitespace and an asterisk\n will be stripped from the beginning of each line other than the first.\n Newlines are included in the output.\n\n Examples:\n\n optional int32 foo = 1; // Comment attached to foo.\n // Comment attached to bar.\n optional int32 bar = 2;\n\n optional string baz = 3;\n // Comment attached to baz.\n // Another line attached to baz.\n\n // Comment attached to qux.\n //\n // Another line attached to qux.\n optional double qux = 4;\n\n // Detached comment for corge. This is not leading or trailing comments\n // to qux or corge because there are blank lines separating it from\n // both.\n\n // Detached comment for corge paragraph 2.\n\n optional string corge = 5;\n /* Block comment attached\n * to corge. Leading asterisks\n * will be removed. */\n /* Block comment attached to\n * grault. */\n optional int32 grault = 6;\n\n // ignored detached comments.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 20], - span: [889, 0, 910, 1], - leadingComments: - ' Describes the relationship between generated code and its original source\n file. A GeneratedCodeInfo message is associated with only one generated\n source file, but may contain references to different source .proto files.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 20, 2, 0], - span: [892, 2, 37], - leadingComments: - ' An Annotation connects some span of text in generated code to an element\n of its generating .proto file.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 20, 3, 0, 2, 0], - span: [896, 4, 44], - leadingComments: - ' Identifies the element in the original source .proto file. This field\n is formatted the same as SourceCodeInfo.Location.path.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 20, 3, 0, 2, 1], - span: [899, 4, 36], - leadingComments: ' Identifies the filesystem path to the original source .proto.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 20, 3, 0, 2, 2], - span: [903, 4, 29], - leadingComments: - ' Identifies the starting offset in bytes in the generated code\n that relates to the identified object.\n', - trailingComments: '', - leadingDetachedComments: [], - }, - { - path: [4, 20, 3, 0, 2, 3], - span: [908, 4, 27], - leadingComments: - ' Identifies the ending offset in bytes in the generated code that\n relates to the identified offset. The end offset should be one past\n the last relevant byte (so the length of the text = end - begin).\n', - trailingComments: '', - leadingDetachedComments: [], - }, - ], + }, { + "path": [4, 19, 2, 0], + "span": [799, 2, 33], + "leadingComments": + ' A Location identifies a piece of source code in a .proto file which\n corresponds to a particular definition. This information is intended\n to be useful to IDEs, code indexers, documentation generators, and similar\n tools.\n\n For example, say we have a file like:\n message Foo {\n optional string foo = 1;\n }\n Let\'s look at just the field definition:\n optional string foo = 1;\n ^ ^^ ^^ ^ ^^^\n a bc de f ghi\n We have the following locations:\n span path represents\n [a,i) [ 4, 0, 2, 0 ] The whole field definition.\n [a,b) [ 4, 0, 2, 0, 4 ] The label (optional).\n [c,d) [ 4, 0, 2, 0, 5 ] The type (string).\n [e,f) [ 4, 0, 2, 0, 1 ] The name (foo).\n [g,h) [ 4, 0, 2, 0, 3 ] The number (1).\n\n Notes:\n - A location may refer to a repeated field itself (i.e. not to any\n particular index within it). This is used whenever a set of elements are\n logically enclosed in a single code segment. For example, an entire\n extend block (possibly containing multiple extension definitions) will\n have an outer location whose path refers to the "extensions" repeated\n field without an index.\n - Multiple locations may have the same path. This happens when a single\n logical declaration is spread out across multiple places. The most\n obvious example is the "extend" block again -- there may be multiple\n extend blocks in the same scope, each of which will have the same path.\n - A location\'s span is not always a subset of its parent\'s span. For\n example, the "extendee" of an extension declaration appears at the\n beginning of the "extend" block and is shared by all extensions within\n the block.\n - Just because a location\'s span is a subset of some other location\'s span\n does not mean that it is a descendant. For example, a "group" defines\n both a type and a field in a single declaration. Thus, the locations\n corresponding to the type and field and their components will overlap.\n - Code which tries to interpret locations should probably be designed to\n ignore those that it doesn\'t understand, as more types of locations could\n be recorded in the future.\n', + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 19, 3, 0, 2, 0], + "span": [824, 4, 44], + "leadingComments": + " Identifies which part of the FileDescriptorProto was defined at this\n location.\n\n Each element is a field number or an index. They form a path from\n the root FileDescriptorProto to the place where the definition. For\n example, this path:\n [ 4, 3, 2, 7, 1 ]\n refers to:\n file.message_type(3) // 4, 3\n .field(7) // 2, 7\n .name() // 1\n This is because FileDescriptorProto.message_type has field number 4:\n repeated DescriptorProto message_type = 4;\n and DescriptorProto.field has field number 2:\n repeated FieldDescriptorProto field = 2;\n and FieldDescriptorProto.name has field number 1:\n optional string name = 1;\n\n Thus, the above path gives the location of a field name. If we removed\n the last element:\n [ 4, 3, 2, 7 ]\n this path refers to the whole field declaration (from the beginning\n of the label to the terminating semicolon).\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 19, 3, 0, 2, 1], + "span": [831, 4, 44], + "leadingComments": + " Always has exactly three or four elements: start line, start column,\n end line (optional, otherwise assumed same as start line), end column.\n These are packed into a single field for efficiency. Note that line\n and column numbers are zero-based -- typically you will want to add\n 1 to each before displaying to a user.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 19, 3, 0, 2, 2], + "span": [880, 4, 41], + "leadingComments": + " If this SourceCodeInfo represents a complete declaration, these are any\n comments appearing before and after the declaration which appear to be\n attached to the declaration.\n\n A series of line comments appearing on consecutive lines, with no other\n tokens appearing on those lines, will be treated as a single comment.\n\n leading_detached_comments will keep paragraphs of comments that appear\n before (but not connected to) the current element. Each paragraph,\n separated by empty lines, will be one comment element in the repeated\n field.\n\n Only the comment content is provided; comment markers (e.g. //) are\n stripped out. For block comments, leading whitespace and an asterisk\n will be stripped from the beginning of each line other than the first.\n Newlines are included in the output.\n\n Examples:\n\n optional int32 foo = 1; // Comment attached to foo.\n // Comment attached to bar.\n optional int32 bar = 2;\n\n optional string baz = 3;\n // Comment attached to baz.\n // Another line attached to baz.\n\n // Comment attached to qux.\n //\n // Another line attached to qux.\n optional double qux = 4;\n\n // Detached comment for corge. This is not leading or trailing comments\n // to qux or corge because there are blank lines separating it from\n // both.\n\n // Detached comment for corge paragraph 2.\n\n optional string corge = 5;\n /* Block comment attached\n * to corge. Leading asterisks\n * will be removed. */\n /* Block comment attached to\n * grault. */\n optional int32 grault = 6;\n\n // ignored detached comments.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 20], + "span": [889, 0, 910, 1], + "leadingComments": + " Describes the relationship between generated code and its original source\n file. A GeneratedCodeInfo message is associated with only one generated\n source file, but may contain references to different source .proto files.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 20, 2, 0], + "span": [892, 2, 37], + "leadingComments": + " An Annotation connects some span of text in generated code to an element\n of its generating .proto file.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 20, 3, 0, 2, 0], + "span": [896, 4, 44], + "leadingComments": + " Identifies the element in the original source .proto file. This field\n is formatted the same as SourceCodeInfo.Location.path.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 20, 3, 0, 2, 1], + "span": [899, 4, 36], + "leadingComments": " Identifies the filesystem path to the original source .proto.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 20, 3, 0, 2, 2], + "span": [903, 4, 29], + "leadingComments": + " Identifies the starting offset in bytes in the generated code\n that relates to the identified object.\n", + "trailingComments": "", + "leadingDetachedComments": [], + }, { + "path": [4, 20, 3, 0, 2, 3], + "span": [908, 4, 27], + "leadingComments": + " Identifies the ending offset in bytes in the generated code that\n relates to the identified offset. The end offset should be one past\n the last relevant byte (so the length of the text = end - begin).\n", + "trailingComments": "", + "leadingDetachedComments": [], + }], }, - syntax: '', + "syntax": "", }), references: { - '.google.protobuf.FileDescriptorSet': FileDescriptorSet, - '.google.protobuf.FileDescriptorProto': FileDescriptorProto, - '.google.protobuf.DescriptorProto': DescriptorProto, - '.google.protobuf.DescriptorProto.ExtensionRange': DescriptorProto_ExtensionRange, - '.google.protobuf.DescriptorProto.ReservedRange': DescriptorProto_ReservedRange, - '.google.protobuf.ExtensionRangeOptions': ExtensionRangeOptions, - '.google.protobuf.FieldDescriptorProto': FieldDescriptorProto, - '.google.protobuf.FieldDescriptorProto.Type': FieldDescriptorProto_Type, - '.google.protobuf.FieldDescriptorProto.Label': FieldDescriptorProto_Label, - '.google.protobuf.OneofDescriptorProto': OneofDescriptorProto, - '.google.protobuf.EnumDescriptorProto': EnumDescriptorProto, - '.google.protobuf.EnumDescriptorProto.EnumReservedRange': EnumDescriptorProto_EnumReservedRange, - '.google.protobuf.EnumValueDescriptorProto': EnumValueDescriptorProto, - '.google.protobuf.ServiceDescriptorProto': ServiceDescriptorProto, - '.google.protobuf.MethodDescriptorProto': MethodDescriptorProto, - '.google.protobuf.FileOptions': FileOptions, - '.google.protobuf.FileOptions.OptimizeMode': FileOptions_OptimizeMode, - '.google.protobuf.MessageOptions': MessageOptions, - '.google.protobuf.FieldOptions': FieldOptions, - '.google.protobuf.FieldOptions.CType': FieldOptions_CType, - '.google.protobuf.FieldOptions.JSType': FieldOptions_JSType, - '.google.protobuf.OneofOptions': OneofOptions, - '.google.protobuf.EnumOptions': EnumOptions, - '.google.protobuf.EnumValueOptions': EnumValueOptions, - '.google.protobuf.ServiceOptions': ServiceOptions, - '.google.protobuf.MethodOptions': MethodOptions, - '.google.protobuf.MethodOptions.IdempotencyLevel': MethodOptions_IdempotencyLevel, - '.google.protobuf.UninterpretedOption': UninterpretedOption, - '.google.protobuf.UninterpretedOption.NamePart': UninterpretedOption_NamePart, - '.google.protobuf.SourceCodeInfo': SourceCodeInfo, - '.google.protobuf.SourceCodeInfo.Location': SourceCodeInfo_Location, - '.google.protobuf.GeneratedCodeInfo': GeneratedCodeInfo, - '.google.protobuf.GeneratedCodeInfo.Annotation': GeneratedCodeInfo_Annotation, + ".google.protobuf.FileDescriptorSet": FileDescriptorSet, + ".google.protobuf.FileDescriptorProto": FileDescriptorProto, + ".google.protobuf.DescriptorProto": DescriptorProto, + ".google.protobuf.DescriptorProto.ExtensionRange": DescriptorProto_ExtensionRange, + ".google.protobuf.DescriptorProto.ReservedRange": DescriptorProto_ReservedRange, + ".google.protobuf.ExtensionRangeOptions": ExtensionRangeOptions, + ".google.protobuf.FieldDescriptorProto": FieldDescriptorProto, + ".google.protobuf.FieldDescriptorProto.Type": FieldDescriptorProto_Type, + ".google.protobuf.FieldDescriptorProto.Label": FieldDescriptorProto_Label, + ".google.protobuf.OneofDescriptorProto": OneofDescriptorProto, + ".google.protobuf.EnumDescriptorProto": EnumDescriptorProto, + ".google.protobuf.EnumDescriptorProto.EnumReservedRange": EnumDescriptorProto_EnumReservedRange, + ".google.protobuf.EnumValueDescriptorProto": EnumValueDescriptorProto, + ".google.protobuf.ServiceDescriptorProto": ServiceDescriptorProto, + ".google.protobuf.MethodDescriptorProto": MethodDescriptorProto, + ".google.protobuf.FileOptions": FileOptions, + ".google.protobuf.FileOptions.OptimizeMode": FileOptions_OptimizeMode, + ".google.protobuf.MessageOptions": MessageOptions, + ".google.protobuf.FieldOptions": FieldOptions, + ".google.protobuf.FieldOptions.CType": FieldOptions_CType, + ".google.protobuf.FieldOptions.JSType": FieldOptions_JSType, + ".google.protobuf.OneofOptions": OneofOptions, + ".google.protobuf.EnumOptions": EnumOptions, + ".google.protobuf.EnumValueOptions": EnumValueOptions, + ".google.protobuf.ServiceOptions": ServiceOptions, + ".google.protobuf.MethodOptions": MethodOptions, + ".google.protobuf.MethodOptions.IdempotencyLevel": MethodOptions_IdempotencyLevel, + ".google.protobuf.UninterpretedOption": UninterpretedOption, + ".google.protobuf.UninterpretedOption.NamePart": UninterpretedOption_NamePart, + ".google.protobuf.SourceCodeInfo": SourceCodeInfo, + ".google.protobuf.SourceCodeInfo.Location": SourceCodeInfo_Location, + ".google.protobuf.GeneratedCodeInfo": GeneratedCodeInfo, + ".google.protobuf.GeneratedCodeInfo.Annotation": GeneratedCodeInfo_Annotation, }, dependencies: [], }; @@ -5570,16 +5244,24 @@ 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'; + 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 longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/options/options.ts b/integration/options/options.ts index 0b93c8002..0ad89d8ed 100644 --- a/integration/options/options.ts +++ b/integration/options/options.ts @@ -1,10 +1,10 @@ /* eslint-disable */ -import { FileDescriptorProto as FileDescriptorProto1 } from 'ts-proto-descriptors'; -import { protoMetadata as protoMetadata1 } from './google/protobuf/descriptor'; -import { protoMetadata as protoMetadata2, Something } from './something/something'; -import * as _m0 from 'protobufjs/minimal'; +import { FileDescriptorProto as FileDescriptorProto1 } from "ts-proto-descriptors"; +import { protoMetadata as protoMetadata1 } from "./google/protobuf/descriptor"; +import { protoMetadata as protoMetadata2, Something } from "./something/something"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export enum MyEnum { FOO = 0, @@ -19,9 +19,11 @@ export interface MyMessage { quux: string | undefined; } -export interface RequestType {} +export interface RequestType { +} -export interface ResponseType {} +export interface ResponseType { +} function createBaseMyMessage(): MyMessage { return { foo: undefined, foo2: undefined, bar: undefined, quux: undefined }; @@ -134,7 +136,7 @@ export class MyServiceClientImpl implements MyService { } MyMethod(request: RequestType): Promise { const data = RequestType.encode(request).finish(); - const promise = this.rpc.request('MyService', 'MyMethod', data); + const promise = this.rpc.request("MyService", "MyMethod", data); return promise.then((data) => ResponseType.decode(new _m0.Reader(data))); } } @@ -157,343 +159,305 @@ export interface ProtoMetadata { options?: { options?: { [key: string]: any }; services?: { - [key: string]: { - options?: { [key: string]: any }; - methods?: { [key: string]: { [key: string]: any } }; - }; - }; - messages?: { - [key: string]: ProtoMetaMessageOptions; - }; - enums?: { - [key: string]: { - options?: { [key: string]: any }; - values?: { [key: string]: { [key: string]: any } }; - }; + [key: string]: { options?: { [key: string]: any }; methods?: { [key: string]: { [key: string]: any } } }; }; + messages?: { [key: string]: ProtoMetaMessageOptions }; + enums?: { [key: string]: { options?: { [key: string]: any }; values?: { [key: string]: { [key: string]: any } } } }; }; } export const protoMetadata: ProtoMetadata = { fileDescriptor: FileDescriptorProto1.fromPartial({ - name: 'options.proto', - package: '', - dependency: ['google/protobuf/descriptor.proto', 'something/something.proto'], - publicDependency: [], - weakDependency: [], - messageType: [ - { - name: 'MyMessage', - field: [ - { - name: 'foo', - number: 1, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 1, - jsonName: 'foo', - options: { - ctype: 0, - packed: false, - jstype: 0, - lazy: false, - deprecated: false, - weak: false, - uninterpretedOption: [], - }, - proto3Optional: true, - }, - { - name: 'foo_2', - number: 2, - label: 1, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 2, - jsonName: 'foo2', - options: { - ctype: 0, - packed: false, - jstype: 0, - lazy: false, - deprecated: false, - weak: false, - uninterpretedOption: [], - }, - proto3Optional: true, - }, - { - name: 'bar', - number: 3, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 3, - jsonName: 'bar', - options: undefined, - proto3Optional: true, - }, - { - name: 'quux', - number: 4, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'quux', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [ - { name: 'qux', options: { uninterpretedOption: [] } }, - { name: '_foo', options: undefined }, - { name: '_foo_2', options: undefined }, - { name: '_bar', options: undefined }, - ], - options: { - messageSetWireFormat: false, - noStandardDescriptorAccessor: false, - deprecated: false, - mapEntry: false, - uninterpretedOption: [], + "name": "options.proto", + "package": "", + "dependency": ["google/protobuf/descriptor.proto", "something/something.proto"], + "publicDependency": [], + "weakDependency": [], + "messageType": [{ + "name": "MyMessage", + "field": [{ + "name": "foo", + "number": 1, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 1, + "jsonName": "foo", + "options": { + "ctype": 0, + "packed": false, + "jstype": 0, + "lazy": false, + "deprecated": false, + "weak": false, + "uninterpretedOption": [], }, - reservedRange: [], - reservedName: [], - }, - { - name: 'RequestType', - field: [], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - { - name: 'ResponseType', - field: [], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [ - { - name: 'MyEnum', - value: [ - { name: 'FOO', number: 0, options: { deprecated: false, uninterpretedOption: [] } }, - { name: 'BAR', number: 1, options: undefined }, - ], - options: { allowAlias: false, deprecated: false, uninterpretedOption: [] }, - reservedRange: [], - reservedName: [], - }, - ], - service: [ - { - name: 'MyService', - method: [ - { - name: 'MyMethod', - inputType: '.RequestType', - outputType: '.ResponseType', - options: { deprecated: false, idempotencyLevel: 0, uninterpretedOption: [] }, - clientStreaming: false, - serverStreaming: false, - }, - ], - options: { deprecated: false, uninterpretedOption: [] }, - }, - ], - extension: [ - { - name: 'my_file_option', - number: 50000, - label: 1, - type: 9, - typeName: '', - extendee: '.google.protobuf.FileOptions', - defaultValue: '', - oneofIndex: 0, - jsonName: 'myFileOption', - options: undefined, - proto3Optional: true, - }, - { - name: 'my_message_option', - number: 50001, - label: 1, - type: 5, - typeName: '', - extendee: '.google.protobuf.MessageOptions', - defaultValue: '', - oneofIndex: 0, - jsonName: 'myMessageOption', - options: undefined, - proto3Optional: true, - }, - { - name: 'my_field_option', - number: 50002, - label: 1, - type: 2, - typeName: '', - extendee: '.google.protobuf.FieldOptions', - defaultValue: '', - oneofIndex: 0, - jsonName: 'myFieldOption', - options: undefined, - proto3Optional: true, - }, - { - name: 'my_oneof_option', - number: 50003, - label: 1, - type: 3, - typeName: '', - extendee: '.google.protobuf.OneofOptions', - defaultValue: '', - oneofIndex: 0, - jsonName: 'myOneofOption', - options: undefined, - proto3Optional: true, - }, - { - name: 'my_enum_option', - number: 50004, - label: 1, - type: 8, - typeName: '', - extendee: '.google.protobuf.EnumOptions', - defaultValue: '', - oneofIndex: 0, - jsonName: 'myEnumOption', - options: undefined, - proto3Optional: true, - }, - { - name: 'my_enum_value_option', - number: 50005, - label: 1, - type: 13, - typeName: '', - extendee: '.google.protobuf.EnumValueOptions', - defaultValue: '', - oneofIndex: 0, - jsonName: 'myEnumValueOption', - options: undefined, - proto3Optional: true, - }, - { - name: 'my_service_option', - number: 50006, - label: 1, - type: 14, - typeName: '.MyEnum', - extendee: '.google.protobuf.ServiceOptions', - defaultValue: '', - oneofIndex: 0, - jsonName: 'myServiceOption', - options: undefined, - proto3Optional: true, - }, - { - name: 'my_method_option', - number: 50007, - label: 1, - type: 11, - typeName: '.MyMessage', - extendee: '.google.protobuf.MethodOptions', - defaultValue: '', - oneofIndex: 0, - jsonName: 'myMethodOption', - options: undefined, - proto3Optional: true, + "proto3Optional": true, + }, { + "name": "foo_2", + "number": 2, + "label": 1, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 2, + "jsonName": "foo2", + "options": { + "ctype": 0, + "packed": false, + "jstype": 0, + "lazy": false, + "deprecated": false, + "weak": false, + "uninterpretedOption": [], + }, + "proto3Optional": true, + }, { + "name": "bar", + "number": 3, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 3, + "jsonName": "bar", + "options": undefined, + "proto3Optional": true, + }, { + "name": "quux", + "number": 4, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "quux", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [ + { "name": "qux", "options": { "uninterpretedOption": [] } }, + { "name": "_foo", "options": undefined }, + { "name": "_foo_2", "options": undefined }, + { "name": "_bar", "options": undefined }, + ], + "options": { + "messageSetWireFormat": false, + "noStandardDescriptorAccessor": false, + "deprecated": false, + "mapEntry": false, + "uninterpretedOption": [], }, - ], - options: { - javaPackage: '', - javaOuterClassname: '', - javaMultipleFiles: false, - javaGenerateEqualsAndHash: false, - javaStringCheckUtf8: false, - optimizeFor: 1, - goPackage: '', - ccGenericServices: false, - javaGenericServices: false, - pyGenericServices: false, - phpGenericServices: false, - deprecated: false, - ccEnableArenas: false, - objcClassPrefix: '', - csharpNamespace: '', - swiftPrefix: '', - phpClassPrefix: '', - phpNamespace: '', - phpMetadataNamespace: '', - rubyPackage: '', - uninterpretedOption: [], + "reservedRange": [], + "reservedName": [], + }, { + "name": "RequestType", + "field": [], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }, { + "name": "ResponseType", + "field": [], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [{ + "name": "MyEnum", + "value": [{ "name": "FOO", "number": 0, "options": { "deprecated": false, "uninterpretedOption": [] } }, { + "name": "BAR", + "number": 1, + "options": undefined, + }], + "options": { "allowAlias": false, "deprecated": false, "uninterpretedOption": [] }, + "reservedRange": [], + "reservedName": [], + }], + "service": [{ + "name": "MyService", + "method": [{ + "name": "MyMethod", + "inputType": ".RequestType", + "outputType": ".ResponseType", + "options": { "deprecated": false, "idempotencyLevel": 0, "uninterpretedOption": [] }, + "clientStreaming": false, + "serverStreaming": false, + }], + "options": { "deprecated": false, "uninterpretedOption": [] }, + }], + "extension": [{ + "name": "my_file_option", + "number": 50000, + "label": 1, + "type": 9, + "typeName": "", + "extendee": ".google.protobuf.FileOptions", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "myFileOption", + "options": undefined, + "proto3Optional": true, + }, { + "name": "my_message_option", + "number": 50001, + "label": 1, + "type": 5, + "typeName": "", + "extendee": ".google.protobuf.MessageOptions", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "myMessageOption", + "options": undefined, + "proto3Optional": true, + }, { + "name": "my_field_option", + "number": 50002, + "label": 1, + "type": 2, + "typeName": "", + "extendee": ".google.protobuf.FieldOptions", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "myFieldOption", + "options": undefined, + "proto3Optional": true, + }, { + "name": "my_oneof_option", + "number": 50003, + "label": 1, + "type": 3, + "typeName": "", + "extendee": ".google.protobuf.OneofOptions", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "myOneofOption", + "options": undefined, + "proto3Optional": true, + }, { + "name": "my_enum_option", + "number": 50004, + "label": 1, + "type": 8, + "typeName": "", + "extendee": ".google.protobuf.EnumOptions", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "myEnumOption", + "options": undefined, + "proto3Optional": true, + }, { + "name": "my_enum_value_option", + "number": 50005, + "label": 1, + "type": 13, + "typeName": "", + "extendee": ".google.protobuf.EnumValueOptions", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "myEnumValueOption", + "options": undefined, + "proto3Optional": true, + }, { + "name": "my_service_option", + "number": 50006, + "label": 1, + "type": 14, + "typeName": ".MyEnum", + "extendee": ".google.protobuf.ServiceOptions", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "myServiceOption", + "options": undefined, + "proto3Optional": true, + }, { + "name": "my_method_option", + "number": 50007, + "label": 1, + "type": 11, + "typeName": ".MyMessage", + "extendee": ".google.protobuf.MethodOptions", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "myMethodOption", + "options": undefined, + "proto3Optional": true, + }], + "options": { + "javaPackage": "", + "javaOuterClassname": "", + "javaMultipleFiles": false, + "javaGenerateEqualsAndHash": false, + "javaStringCheckUtf8": false, + "optimizeFor": 1, + "goPackage": "", + "ccGenericServices": false, + "javaGenericServices": false, + "pyGenericServices": false, + "phpGenericServices": false, + "deprecated": false, + "ccEnableArenas": false, + "objcClassPrefix": "", + "csharpNamespace": "", + "swiftPrefix": "", + "phpClassPrefix": "", + "phpNamespace": "", + "phpMetadataNamespace": "", + "rubyPackage": "", + "uninterpretedOption": [], }, - sourceCodeInfo: { location: [] }, - syntax: 'proto3', + "sourceCodeInfo": { "location": [] }, + "syntax": "proto3", }), references: { - '.MyEnum': MyEnum, - '.MyMessage': MyMessage, - '.RequestType': RequestType, - '.ResponseType': ResponseType, - '.MyService': MyServiceClientImpl, + ".MyEnum": MyEnum, + ".MyMessage": MyMessage, + ".RequestType": RequestType, + ".ResponseType": ResponseType, + ".MyService": MyServiceClientImpl, }, dependencies: [protoMetadata1, protoMetadata2], options: { - options: { my_file_option: 'Hello world!' }, + options: { "my_file_option": "Hello world!" }, messages: { - MyMessage: { - options: { my_message_option: 1234 }, + "MyMessage": { + options: { "my_message_option": 1234 }, fields: { - foo: { my_field_option: 4.5 }, - foo_2: { something: Something.decode(Buffer.from('CgV3b3JsZBIDe9kC', 'base64')) }, + "foo": { "my_field_option": 4.5 }, + "foo_2": { "something": Something.decode(Buffer.from("CgV3b3JsZBIDe9kC", "base64")) }, }, - oneof: { qux: { my_oneof_option: 42 } }, + oneof: { "qux": { "my_oneof_option": 42 } }, }, }, services: { - MyService: { - options: { my_service_option: 0 }, + "MyService": { + options: { "my_service_option": 0 }, methods: { - MyMethod: { - my_method_option: MyMessage.decode(Buffer.from('CJYBEJYBGgtTb21lIHN0cmluZyILU29tZSBzdHJpbmc=', 'base64')), + "MyMethod": { + "my_method_option": MyMessage.decode(Buffer.from("CJYBEJYBGgtTb21lIHN0cmluZyILU29tZSBzdHJpbmc=", "base64")), }, }, }, }, - enums: { - MyEnum: { - options: { my_enum_option: true }, - values: { FOO: { my_enum_value_option: 321 } }, - }, - }, + enums: { "MyEnum": { options: { "my_enum_option": true }, values: { "FOO": { "my_enum_value_option": 321 } } } }, }, }; diff --git a/integration/options/something/something.ts b/integration/options/something/something.ts index b7194abad..fec4af4d3 100644 --- a/integration/options/something/something.ts +++ b/integration/options/something/something.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { FileDescriptorProto as FileDescriptorProto1 } from 'ts-proto-descriptors'; -import { protoMetadata as protoMetadata1 } from '../google/protobuf/descriptor'; -import * as _m0 from 'protobufjs/minimal'; +import { FileDescriptorProto as FileDescriptorProto1 } from "ts-proto-descriptors"; +import { protoMetadata as protoMetadata1 } from "../google/protobuf/descriptor"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'something'; +export const protobufPackage = "something"; export interface Something { hello: string; @@ -11,12 +11,12 @@ export interface Something { } function createBaseSomething(): Something { - return { hello: '', foo: [] }; + return { hello: "", foo: [] }; } export const Something = { encode(message: Something, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.hello !== '') { + if (message.hello !== "") { writer.uint32(10).string(message.hello); } writer.uint32(18).fork(); @@ -70,92 +70,75 @@ export interface ProtoMetadata { options?: { options?: { [key: string]: any }; services?: { - [key: string]: { - options?: { [key: string]: any }; - methods?: { [key: string]: { [key: string]: any } }; - }; - }; - messages?: { - [key: string]: ProtoMetaMessageOptions; - }; - enums?: { - [key: string]: { - options?: { [key: string]: any }; - values?: { [key: string]: { [key: string]: any } }; - }; + [key: string]: { options?: { [key: string]: any }; methods?: { [key: string]: { [key: string]: any } } }; }; + messages?: { [key: string]: ProtoMetaMessageOptions }; + enums?: { [key: string]: { options?: { [key: string]: any }; values?: { [key: string]: { [key: string]: any } } } }; }; } export const protoMetadata: ProtoMetadata = { fileDescriptor: FileDescriptorProto1.fromPartial({ - name: 'something/something.proto', - package: 'something', - dependency: ['google/protobuf/descriptor.proto'], - publicDependency: [], - weakDependency: [], - messageType: [ - { - name: 'Something', - field: [ - { - name: 'hello', - number: 1, - label: 1, - type: 9, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'hello', - options: undefined, - proto3Optional: false, - }, - { - name: 'foo', - number: 2, - label: 3, - type: 5, - typeName: '', - extendee: '', - defaultValue: '', - oneofIndex: 0, - jsonName: 'foo', - options: undefined, - proto3Optional: false, - }, - ], - extension: [], - nestedType: [], - enumType: [], - extensionRange: [], - oneofDecl: [], - options: undefined, - reservedRange: [], - reservedName: [], - }, - ], - enumType: [], - service: [], - extension: [ - { - name: 'something', - number: 1000, - label: 1, - type: 11, - typeName: '.something.Something', - extendee: '.google.protobuf.FieldOptions', - defaultValue: '', - oneofIndex: 0, - jsonName: 'something', - options: undefined, - proto3Optional: true, - }, - ], - options: undefined, - sourceCodeInfo: { location: [] }, - syntax: 'proto3', + "name": "something/something.proto", + "package": "something", + "dependency": ["google/protobuf/descriptor.proto"], + "publicDependency": [], + "weakDependency": [], + "messageType": [{ + "name": "Something", + "field": [{ + "name": "hello", + "number": 1, + "label": 1, + "type": 9, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "hello", + "options": undefined, + "proto3Optional": false, + }, { + "name": "foo", + "number": 2, + "label": 3, + "type": 5, + "typeName": "", + "extendee": "", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "foo", + "options": undefined, + "proto3Optional": false, + }], + "extension": [], + "nestedType": [], + "enumType": [], + "extensionRange": [], + "oneofDecl": [], + "options": undefined, + "reservedRange": [], + "reservedName": [], + }], + "enumType": [], + "service": [], + "extension": [{ + "name": "something", + "number": 1000, + "label": 1, + "type": 11, + "typeName": ".something.Something", + "extendee": ".google.protobuf.FieldOptions", + "defaultValue": "", + "oneofIndex": 0, + "jsonName": "something", + "options": undefined, + "proto3Optional": true, + }], + "options": undefined, + "sourceCodeInfo": { "location": [] }, + "syntax": "proto3", }), - references: { '.something.Something': Something }, + references: { ".something.Something": Something }, dependencies: [protoMetadata1], }; diff --git a/integration/point/point.ts b/integration/point/point.ts index 5c851def5..9990cabd0 100644 --- a/integration/point/point.ts +++ b/integration/point/point.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface Point { lat: number; @@ -50,10 +50,7 @@ export const Point = { }, fromJSON(object: any): Point { - return { - lat: isSet(object.lat) ? Number(object.lat) : 0, - lng: isSet(object.lng) ? Number(object.lng) : 0, - }; + return { lat: isSet(object.lat) ? Number(object.lat) : 0, lng: isSet(object.lng) ? Number(object.lng) : 0 }; }, toJSON(message: Point): unknown { @@ -123,27 +120,21 @@ export const Area = { fromPartial, I>>(object: I): Area { const message = createBaseArea(); - message.nw = object.nw !== undefined && object.nw !== null ? Point.fromPartial(object.nw) : undefined; - message.se = object.se !== undefined && object.se !== null ? Point.fromPartial(object.se) : undefined; + message.nw = (object.nw !== undefined && object.nw !== null) ? Point.fromPartial(object.nw) : undefined; + message.se = (object.se !== undefined && object.se !== null) ? Point.fromPartial(object.se) : undefined; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/reserved-words/reserved-words.ts b/integration/reserved-words/reserved-words.ts index 28e7945c0..7f45ab11e 100644 --- a/integration/reserved-words/reserved-words.ts +++ b/integration/reserved-words/reserved-words.ts @@ -1,9 +1,10 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; -export interface Record {} +export interface Record { +} function createBaseRecord(): Record { return {}; @@ -46,17 +47,11 @@ export const Record = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; diff --git a/integration/return-observable/observable.ts b/integration/return-observable/observable.ts index f179b7d7a..5c076d46b 100644 --- a/integration/return-observable/observable.ts +++ b/integration/return-observable/observable.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { Observable } from 'rxjs'; -import * as _m0 from 'protobufjs/minimal'; +import { Observable } from "rxjs"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface ProduceRequest { ingredients: string; @@ -13,12 +13,12 @@ export interface ProduceReply { } function createBaseProduceRequest(): ProduceRequest { - return { ingredients: '' }; + return { ingredients: "" }; } export const ProduceRequest = { encode(message: ProduceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.ingredients !== '') { + if (message.ingredients !== "") { writer.uint32(10).string(message.ingredients); } return writer; @@ -43,9 +43,7 @@ export const ProduceRequest = { }, fromJSON(object: any): ProduceRequest { - return { - ingredients: isSet(object.ingredients) ? String(object.ingredients) : '', - }; + return { ingredients: isSet(object.ingredients) ? String(object.ingredients) : "" }; }, toJSON(message: ProduceRequest): unknown { @@ -56,18 +54,18 @@ export const ProduceRequest = { fromPartial, I>>(object: I): ProduceRequest { const message = createBaseProduceRequest(); - message.ingredients = object.ingredients ?? ''; + message.ingredients = object.ingredients ?? ""; return message; }, }; function createBaseProduceReply(): ProduceReply { - return { result: '' }; + return { result: "" }; } export const ProduceReply = { encode(message: ProduceReply, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.result !== '') { + if (message.result !== "") { writer.uint32(10).string(message.result); } return writer; @@ -92,9 +90,7 @@ export const ProduceReply = { }, fromJSON(object: any): ProduceReply { - return { - result: isSet(object.result) ? String(object.result) : '', - }; + return { result: isSet(object.result) ? String(object.result) : "" }; }, toJSON(message: ProduceReply): unknown { @@ -105,7 +101,7 @@ export const ProduceReply = { fromPartial, I>>(object: I): ProduceReply { const message = createBaseProduceReply(); - message.result = object.result ?? ''; + message.result = object.result ?? ""; return message; }, }; @@ -116,19 +112,13 @@ export interface Factory { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/simple-deprecated-fields/simple.ts b/integration/simple-deprecated-fields/simple.ts index bbc9f3191..b78da77d7 100644 --- a/integration/simple-deprecated-fields/simple.ts +++ b/integration/simple-deprecated-fields/simple.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface Simple { /** @@ -21,7 +21,9 @@ export interface Simple { * * @deprecated */ - child: Child | undefined; + child: + | Child + | undefined; /** @deprecated */ testField: string; testNotDeprecated: string; @@ -32,12 +34,12 @@ export interface Child { } function createBaseSimple(): Simple { - return { name: '', age: 0, child: undefined, testField: '', testNotDeprecated: '' }; + return { name: "", age: 0, child: undefined, testField: "", testNotDeprecated: "" }; } export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== 0) { @@ -46,10 +48,10 @@ export const Simple = { if (message.child !== undefined) { Child.encode(message.child, writer.uint32(26).fork()).ldelim(); } - if (message.testField !== '') { + if (message.testField !== "") { writer.uint32(34).string(message.testField); } - if (message.testNotDeprecated !== '') { + if (message.testNotDeprecated !== "") { writer.uint32(42).string(message.testNotDeprecated); } return writer; @@ -87,11 +89,11 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, - testField: isSet(object.testField) ? String(object.testField) : '', - testNotDeprecated: isSet(object.testNotDeprecated) ? String(object.testNotDeprecated) : '', + testField: isSet(object.testField) ? String(object.testField) : "", + testNotDeprecated: isSet(object.testNotDeprecated) ? String(object.testNotDeprecated) : "", }; }, @@ -107,22 +109,22 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.age = object.age ?? 0; - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; - message.testField = object.testField ?? ''; - message.testNotDeprecated = object.testNotDeprecated ?? ''; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; + message.testField = object.testField ?? ""; + message.testNotDeprecated = object.testNotDeprecated ?? ""; return message; }, }; function createBaseChild(): Child { - return { name: '' }; + return { name: "" }; } export const Child = { encode(message: Child, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -147,9 +149,7 @@ export const Child = { }, fromJSON(object: any): Child { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Child): unknown { @@ -160,26 +160,20 @@ export const Child = { fromPartial, I>>(object: I): Child { const message = createBaseChild(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/simple-esmodule-interop/simple.ts b/integration/simple-esmodule-interop/simple.ts index ffd840b55..42cb50832 100644 --- a/integration/simple-esmodule-interop/simple.ts +++ b/integration/simple-esmodule-interop/simple.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import Long from 'long'; -import _m0 from 'protobufjs/minimal'; +import Long from "long"; +import _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface Simple { name: string; @@ -25,12 +25,12 @@ export interface Numbers { } function createBaseSimple(): Simple { - return { name: '', age: 0 }; + return { name: "", age: 0 }; } export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== 0) { @@ -61,10 +61,7 @@ export const Simple = { }, fromJSON(object: any): Simple { - return { - name: isSet(object.name) ? String(object.name) : '', - age: isSet(object.age) ? Number(object.age) : 0, - }; + return { name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0 }; }, toJSON(message: Simple): unknown { @@ -76,7 +73,7 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.age = object.age ?? 0; return message; }, @@ -247,33 +244,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple-json-name/google/protobuf/timestamp.ts b/integration/simple-json-name/google/protobuf/timestamp.ts index c52fb2549..5497f7183 100644 --- a/integration/simple-json-name/google/protobuf/timestamp.ts +++ b/integration/simple-json-name/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple-json-name/simple.ts b/integration/simple-json-name/simple.ts index bd0cd5e0b..d9aff45d5 100644 --- a/integration/simple-json-name/simple.ts +++ b/integration/simple-json-name/simple.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { Timestamp } from './google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface Simple { name: string; @@ -17,20 +17,20 @@ export interface Simple { function createBaseSimple(): Simple { return { - name: '', + name: "", age: undefined, createdAt: undefined, - hyphen: '', - spaces: '', - dollarStart: '', - dollarEnd: '', + hyphen: "", + spaces: "", + dollarStart: "", + dollarEnd: "", hyphenList: [], }; } export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== undefined) { @@ -39,16 +39,16 @@ export const Simple = { if (message.createdAt !== undefined) { Timestamp.encode(toTimestamp(message.createdAt), writer.uint32(74).fork()).ldelim(); } - if (message.hyphen !== '') { + if (message.hyphen !== "") { writer.uint32(26).string(message.hyphen); } - if (message.spaces !== '') { + if (message.spaces !== "") { writer.uint32(34).string(message.spaces); } - if (message.dollarStart !== '') { + if (message.dollarStart !== "") { writer.uint32(42).string(message.dollarStart); } - if (message.dollarEnd !== '') { + if (message.dollarEnd !== "") { writer.uint32(50).string(message.dollarEnd); } for (const v of message.hyphenList) { @@ -98,14 +98,14 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.other_name) ? String(object.other_name) : '', + name: isSet(object.other_name) ? String(object.other_name) : "", age: isSet(object.other_age) ? Number(object.other_age) : undefined, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, - hyphen: isSet(object['hyphened-name']) ? String(object['hyphened-name']) : '', - spaces: isSet(object['name with spaces']) ? String(object['name with spaces']) : '', - dollarStart: isSet(object.$dollar) ? String(object.$dollar) : '', - dollarEnd: isSet(object.dollar$) ? String(object.dollar$) : '', - hyphenList: Array.isArray(object?.['hyphen-list']) ? object['hyphen-list'].map((e: any) => String(e)) : [], + hyphen: isSet(object["hyphened-name"]) ? String(object["hyphened-name"]) : "", + spaces: isSet(object["name with spaces"]) ? String(object["name with spaces"]) : "", + dollarStart: isSet(object.$dollar) ? String(object.$dollar) : "", + dollarEnd: isSet(object.dollar$) ? String(object.dollar$) : "", + hyphenList: Array.isArray(object?.["hyphen-list"]) ? object["hyphen-list"].map((e: any) => String(e)) : [], }; }, @@ -114,27 +114,27 @@ export const Simple = { message.name !== undefined && (obj.other_name = message.name); message.age !== undefined && (obj.other_age = Math.round(message.age)); message.createdAt !== undefined && (obj.createdAt = message.createdAt.toISOString()); - message.hyphen !== undefined && (obj['hyphened-name'] = message.hyphen); - message.spaces !== undefined && (obj['name with spaces'] = message.spaces); + message.hyphen !== undefined && (obj["hyphened-name"] = message.hyphen); + message.spaces !== undefined && (obj["name with spaces"] = message.spaces); message.dollarStart !== undefined && (obj.$dollar = message.dollarStart); message.dollarEnd !== undefined && (obj.dollar$ = message.dollarEnd); if (message.hyphenList) { - obj['hyphen-list'] = message.hyphenList.map((e) => e); + obj["hyphen-list"] = message.hyphenList.map((e) => e); } else { - obj['hyphen-list'] = []; + obj["hyphen-list"] = []; } return obj; }, fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.age = object.age ?? undefined; message.createdAt = object.createdAt ?? undefined; - message.hyphen = object.hyphen ?? ''; - message.spaces = object.spaces ?? ''; - message.dollarStart = object.dollarStart ?? ''; - message.dollarEnd = object.dollarEnd ?? ''; + message.hyphen = object.hyphen ?? ""; + message.spaces = object.spaces ?? ""; + message.dollarStart = object.dollarStart ?? ""; + message.dollarEnd = object.dollarEnd ?? ""; message.hyphenList = object.hyphenList?.map((e) => e) || []; return message; }, @@ -142,19 +142,13 @@ export const Simple = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -172,7 +166,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/simple-long-string/google/protobuf/timestamp.ts b/integration/simple-long-string/google/protobuf/timestamp.ts index b820ff3b8..3034b19ae 100644 --- a/integration/simple-long-string/google/protobuf/timestamp.ts +++ b/integration/simple-long-string/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -114,12 +112,12 @@ export interface Timestamp { } function createBaseTimestamp(): Timestamp { - return { seconds: '0', nanos: 0 }; + return { seconds: "0", nanos: 0 }; } export const Timestamp = { encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.seconds !== '0') { + if (message.seconds !== "0") { writer.uint32(8).int64(message.seconds); } if (message.nanos !== 0) { @@ -151,7 +149,7 @@ export const Timestamp = { fromJSON(object: any): Timestamp { return { - seconds: isSet(object.seconds) ? String(object.seconds) : '0', + seconds: isSet(object.seconds) ? String(object.seconds) : "0", nanos: isSet(object.nanos) ? Number(object.nanos) : 0, }; }, @@ -165,7 +163,7 @@ export const Timestamp = { fromPartial, I>>(object: I): Timestamp { const message = createBaseTimestamp(); - message.seconds = object.seconds ?? '0'; + message.seconds = object.seconds ?? "0"; message.nanos = object.nanos ?? 0; return message; }, @@ -173,19 +171,13 @@ export const Timestamp = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToString(long: Long) { diff --git a/integration/simple-long-string/google/protobuf/wrappers.ts b/integration/simple-long-string/google/protobuf/wrappers.ts index b60476eb4..9deb01d20 100644 --- a/integration/simple-long-string/google/protobuf/wrappers.ts +++ b/integration/simple-long-string/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -193,12 +189,12 @@ export const FloatValue = { }; function createBaseInt64Value(): Int64Value { - return { value: '0' }; + return { value: "0" }; } export const Int64Value = { encode(message: Int64Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '0') { + if (message.value !== "0") { writer.uint32(8).int64(message.value); } return writer; @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? String(object.value) : '0', - }; + return { value: isSet(object.value) ? String(object.value) : "0" }; }, toJSON(message: Int64Value): unknown { @@ -236,18 +230,18 @@ export const Int64Value = { fromPartial, I>>(object: I): Int64Value { const message = createBaseInt64Value(); - message.value = object.value ?? '0'; + message.value = object.value ?? "0"; return message; }, }; function createBaseUInt64Value(): UInt64Value { - return { value: '0' }; + return { value: "0" }; } export const UInt64Value = { encode(message: UInt64Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '0') { + if (message.value !== "0") { writer.uint32(8).uint64(message.value); } return writer; @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? String(object.value) : '0', - }; + return { value: isSet(object.value) ? String(object.value) : "0" }; }, toJSON(message: UInt64Value): unknown { @@ -285,7 +277,7 @@ export const UInt64Value = { fromPartial, I>>(object: I): UInt64Value { const message = createBaseUInt64Value(); - message.value = object.value ?? '0'; + message.value = object.value ?? "0"; return message; }, }; @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial, I>>(object: I): StringValue { const message = createBaseStringValue(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), - }; + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,31 +552,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function longToString(long: Long) { diff --git a/integration/simple-long-string/simple.ts b/integration/simple-long-string/simple.ts index 57ed2adcb..609fb19d6 100644 --- a/integration/simple-long-string/simple.ts +++ b/integration/simple-long-string/simple.ts @@ -1,10 +1,10 @@ /* eslint-disable */ -import { Timestamp } from './google/protobuf/timestamp'; -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; -import { UInt64Value } from './google/protobuf/wrappers'; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; +import { UInt64Value } from "./google/protobuf/wrappers"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface Numbers { double: number; @@ -28,15 +28,15 @@ function createBaseNumbers(): Numbers { double: 0, float: 0, int32: 0, - int64: '0', + int64: "0", uint32: 0, - uint64: '0', + uint64: "0", sint32: 0, - sint64: '0', + sint64: "0", fixed32: 0, - fixed64: '0', + fixed64: "0", sfixed32: 0, - sfixed64: '0', + sfixed64: "0", guint64: undefined, timestamp: undefined, }; @@ -53,31 +53,31 @@ export const Numbers = { if (message.int32 !== 0) { writer.uint32(24).int32(message.int32); } - if (message.int64 !== '0') { + if (message.int64 !== "0") { writer.uint32(32).int64(message.int64); } if (message.uint32 !== 0) { writer.uint32(40).uint32(message.uint32); } - if (message.uint64 !== '0') { + if (message.uint64 !== "0") { writer.uint32(48).uint64(message.uint64); } if (message.sint32 !== 0) { writer.uint32(56).sint32(message.sint32); } - if (message.sint64 !== '0') { + if (message.sint64 !== "0") { writer.uint32(64).sint64(message.sint64); } if (message.fixed32 !== 0) { writer.uint32(77).fixed32(message.fixed32); } - if (message.fixed64 !== '0') { + if (message.fixed64 !== "0") { writer.uint32(81).fixed64(message.fixed64); } if (message.sfixed32 !== 0) { writer.uint32(93).sfixed32(message.sfixed32); } - if (message.sfixed64 !== '0') { + if (message.sfixed64 !== "0") { writer.uint32(97).sfixed64(message.sfixed64); } if (message.guint64 !== undefined) { @@ -151,15 +151,15 @@ export const Numbers = { double: isSet(object.double) ? Number(object.double) : 0, float: isSet(object.float) ? Number(object.float) : 0, int32: isSet(object.int32) ? Number(object.int32) : 0, - int64: isSet(object.int64) ? String(object.int64) : '0', + int64: isSet(object.int64) ? String(object.int64) : "0", uint32: isSet(object.uint32) ? Number(object.uint32) : 0, - uint64: isSet(object.uint64) ? String(object.uint64) : '0', + uint64: isSet(object.uint64) ? String(object.uint64) : "0", sint32: isSet(object.sint32) ? Number(object.sint32) : 0, - sint64: isSet(object.sint64) ? String(object.sint64) : '0', + sint64: isSet(object.sint64) ? String(object.sint64) : "0", fixed32: isSet(object.fixed32) ? Number(object.fixed32) : 0, - fixed64: isSet(object.fixed64) ? String(object.fixed64) : '0', + fixed64: isSet(object.fixed64) ? String(object.fixed64) : "0", sfixed32: isSet(object.sfixed32) ? Number(object.sfixed32) : 0, - sfixed64: isSet(object.sfixed64) ? String(object.sfixed64) : '0', + sfixed64: isSet(object.sfixed64) ? String(object.sfixed64) : "0", guint64: isSet(object.guint64) ? String(object.guint64) : undefined, timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, }; @@ -189,15 +189,15 @@ export const Numbers = { message.double = object.double ?? 0; message.float = object.float ?? 0; message.int32 = object.int32 ?? 0; - message.int64 = object.int64 ?? '0'; + message.int64 = object.int64 ?? "0"; message.uint32 = object.uint32 ?? 0; - message.uint64 = object.uint64 ?? '0'; + message.uint64 = object.uint64 ?? "0"; message.sint32 = object.sint32 ?? 0; - message.sint64 = object.sint64 ?? '0'; + message.sint64 = object.sint64 ?? "0"; message.fixed32 = object.fixed32 ?? 0; - message.fixed64 = object.fixed64 ?? '0'; + message.fixed64 = object.fixed64 ?? "0"; message.sfixed32 = object.sfixed32 ?? 0; - message.sfixed64 = object.sfixed64 ?? '0'; + message.sfixed64 = object.sfixed64 ?? "0"; message.guint64 = object.guint64 ?? undefined; message.timestamp = object.timestamp ?? undefined; return message; @@ -206,19 +206,13 @@ export const Numbers = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -236,7 +230,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/simple-long/google/protobuf/wrappers.ts b/integration/simple-long/google/protobuf/wrappers.ts index 89bb64912..c7b5789ab 100644 --- a/integration/simple-long/google/protobuf/wrappers.ts +++ b/integration/simple-long/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? Long.fromValue(object.value) : Long.ZERO, - }; + return { value: isSet(object.value) ? Long.fromValue(object.value) : Long.ZERO }; }, toJSON(message: Int64Value): unknown { @@ -236,7 +230,7 @@ export const Int64Value = { fromPartial, I>>(object: I): Int64Value { const message = createBaseInt64Value(); - message.value = object.value !== undefined && object.value !== null ? Long.fromValue(object.value) : Long.ZERO; + message.value = (object.value !== undefined && object.value !== null) ? Long.fromValue(object.value) : Long.ZERO; return message; }, }; @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? Long.fromValue(object.value) : Long.UZERO, - }; + return { value: isSet(object.value) ? Long.fromValue(object.value) : Long.UZERO }; }, toJSON(message: UInt64Value): unknown { @@ -285,7 +277,7 @@ export const UInt64Value = { fromPartial, I>>(object: I): UInt64Value { const message = createBaseUInt64Value(); - message.value = object.value !== undefined && object.value !== null ? Long.fromValue(object.value) : Long.UZERO; + message.value = (object.value !== undefined && object.value !== null) ? Long.fromValue(object.value) : Long.UZERO; return message; }, }; @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial, I>>(object: I): StringValue { const message = createBaseStringValue(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), - }; + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,33 +552,26 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + return globalThis.btoa(bin.join("")); } } type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -export type DeepPartial = T extends Builtin - ? T - : T extends Long - ? string | number | Long - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Long ? string | number | Long : 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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; // If you get a compile-error about 'Constructor and ... have no overlap', diff --git a/integration/simple-long/simple.ts b/integration/simple-long/simple.ts index 447c6439c..453afe1ab 100644 --- a/integration/simple-long/simple.ts +++ b/integration/simple-long/simple.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; -import { StringValue, Int32Value, BoolValue, Int64Value } from './google/protobuf/wrappers'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; +import { BoolValue, Int32Value, Int64Value, StringValue } from "./google/protobuf/wrappers"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface SimpleWithWrappers { name: string | undefined; @@ -148,8 +148,9 @@ export const SimpleWithWrappers = { message.name = object.name ?? undefined; message.age = object.age ?? undefined; message.enabled = object.enabled ?? undefined; - message.bananas = - object.bananas !== undefined && object.bananas !== null ? Long.fromValue(object.bananas) : undefined; + message.bananas = (object.bananas !== undefined && object.bananas !== null) + ? Long.fromValue(object.bananas) + : undefined; message.coins = object.coins?.map((e) => e) || []; message.snacks = object.snacks?.map((e) => e) || []; return message; @@ -211,21 +212,21 @@ export const SimpleWithMap = { return { nameLookup: isObject(object.nameLookup) ? Object.entries(object.nameLookup).reduce<{ [key: string]: string }>((acc, [key, value]) => { - acc[key] = String(value); - return acc; - }, {}) + acc[key] = String(value); + return acc; + }, {}) : {}, intLookup: isObject(object.intLookup) ? Object.entries(object.intLookup).reduce<{ [key: number]: number }>((acc, [key, value]) => { - acc[Number(key)] = Number(value); - return acc; - }, {}) + acc[Number(key)] = Number(value); + return acc; + }, {}) : {}, longLookup: isObject(object.longLookup) ? Object.entries(object.longLookup).reduce<{ [key: string]: Long }>((acc, [key, value]) => { - acc[key] = Long.fromValue(value as Long | string); - return acc; - }, {}) + acc[key] = Long.fromValue(value as Long | string); + return acc; + }, {}) : {}, }; }, @@ -262,7 +263,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { @@ -271,7 +272,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.longLookup = Object.entries(object.longLookup ?? {}).reduce<{ [key: string]: Long }>( (acc, [key, value]) => { @@ -280,22 +281,22 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); return message; }, }; function createBaseSimpleWithMap_NameLookupEntry(): SimpleWithMap_NameLookupEntry { - return { key: '', value: '' }; + return { key: "", value: "" }; } export const SimpleWithMap_NameLookupEntry = { encode(message: SimpleWithMap_NameLookupEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -323,10 +324,7 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object.value) ? String(object.value) : '', - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -337,11 +335,11 @@ export const SimpleWithMap_NameLookupEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_NameLookupEntry { const message = createBaseSimpleWithMap_NameLookupEntry(); - message.key = object.key ?? ''; - message.value = object.value ?? ''; + message.key = object.key ?? ""; + message.value = object.value ?? ""; return message; }, }; @@ -383,10 +381,7 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { - key: isSet(object.key) ? Number(object.key) : 0, - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -405,12 +400,12 @@ export const SimpleWithMap_IntLookupEntry = { }; function createBaseSimpleWithMap_LongLookupEntry(): SimpleWithMap_LongLookupEntry { - return { key: '', value: Long.ZERO }; + return { key: "", value: Long.ZERO }; } export const SimpleWithMap_LongLookupEntry = { encode(message: SimpleWithMap_LongLookupEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (!message.value.isZero()) { @@ -442,7 +437,7 @@ export const SimpleWithMap_LongLookupEntry = { fromJSON(object: any): SimpleWithMap_LongLookupEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? Long.fromValue(object.value) : Long.ZERO, }; }, @@ -455,11 +450,11 @@ export const SimpleWithMap_LongLookupEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_LongLookupEntry { const message = createBaseSimpleWithMap_LongLookupEntry(); - message.key = object.key ?? ''; - message.value = object.value !== undefined && object.value !== null ? Long.fromValue(object.value) : Long.ZERO; + message.key = object.key ?? ""; + message.value = (object.value !== undefined && object.value !== null) ? Long.fromValue(object.value) : Long.ZERO; return message; }, }; @@ -634,17 +629,23 @@ export const Numbers = { message.double = object.double ?? 0; message.float = object.float ?? 0; message.int32 = object.int32 ?? 0; - message.int64 = object.int64 !== undefined && object.int64 !== null ? Long.fromValue(object.int64) : Long.ZERO; + message.int64 = (object.int64 !== undefined && object.int64 !== null) ? Long.fromValue(object.int64) : Long.ZERO; message.uint32 = object.uint32 ?? 0; - message.uint64 = object.uint64 !== undefined && object.uint64 !== null ? Long.fromValue(object.uint64) : Long.UZERO; + message.uint64 = (object.uint64 !== undefined && object.uint64 !== null) + ? Long.fromValue(object.uint64) + : Long.UZERO; message.sint32 = object.sint32 ?? 0; - message.sint64 = object.sint64 !== undefined && object.sint64 !== null ? Long.fromValue(object.sint64) : Long.ZERO; + message.sint64 = (object.sint64 !== undefined && object.sint64 !== null) + ? Long.fromValue(object.sint64) + : Long.ZERO; message.fixed32 = object.fixed32 ?? 0; - message.fixed64 = - object.fixed64 !== undefined && object.fixed64 !== null ? Long.fromValue(object.fixed64) : Long.UZERO; + message.fixed64 = (object.fixed64 !== undefined && object.fixed64 !== null) + ? Long.fromValue(object.fixed64) + : Long.UZERO; message.sfixed32 = object.sfixed32 ?? 0; - message.sfixed64 = - object.sfixed64 !== undefined && object.sfixed64 !== null ? Long.fromValue(object.sfixed64) : Long.ZERO; + message.sfixed64 = (object.sfixed64 !== undefined && object.sfixed64 !== null) + ? Long.fromValue(object.sfixed64) + : Long.ZERO; message.manyUint64 = object.manyUint64?.map((e) => Long.fromValue(e)) || []; return message; }, @@ -652,21 +653,14 @@ export const Numbers = { type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; -export type DeepPartial = T extends Builtin - ? T - : T extends Long - ? string | number | Long - : T extends Array - ? Array> - : T extends ReadonlyArray - ? ReadonlyArray> - : T extends {} - ? { [K in keyof T]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Long ? string | number | Long : 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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; // If you get a compile-error about 'Constructor and ... have no overlap', @@ -677,7 +671,7 @@ if (_m0.util.Long !== Long) { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/simple-optionals/google/protobuf/timestamp.ts b/integration/simple-optionals/google/protobuf/timestamp.ts index c52fb2549..5497f7183 100644 --- a/integration/simple-optionals/google/protobuf/timestamp.ts +++ b/integration/simple-optionals/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple-optionals/google/protobuf/wrappers.ts b/integration/simple-optionals/google/protobuf/wrappers.ts index 5e90fd4da..3145298cb 100644 --- a/integration/simple-optionals/google/protobuf/wrappers.ts +++ b/integration/simple-optionals/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial, I>>(object: I): StringValue { const message = createBaseStringValue(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), - }; + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,36 +552,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple-optionals/import_dir/thing.ts b/integration/simple-optionals/import_dir/thing.ts index 68582c900..c796f8574 100644 --- a/integration/simple-optionals/import_dir/thing.ts +++ b/integration/simple-optionals/import_dir/thing.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { Timestamp } from '../google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; +import { Timestamp } from "../google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface ImportedThing { createdAt?: Date; @@ -39,9 +39,7 @@ export const ImportedThing = { }, fromJSON(object: any): ImportedThing { - return { - createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, - }; + return { createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined }; }, toJSON(message: ImportedThing): unknown { @@ -59,19 +57,13 @@ export const ImportedThing = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -89,7 +81,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/simple-optionals/simple.ts b/integration/simple-optionals/simple.ts index 2f418a53e..c8f1520c0 100644 --- a/integration/simple-optionals/simple.ts +++ b/integration/simple-optionals/simple.ts @@ -1,11 +1,11 @@ /* eslint-disable */ -import { ImportedThing } from './import_dir/thing'; -import { Timestamp } from './google/protobuf/timestamp'; -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; -import { StringValue, Int32Value, BoolValue } from './google/protobuf/wrappers'; +import { ImportedThing } from "./import_dir/thing"; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; +import { BoolValue, Int32Value, StringValue } from "./google/protobuf/wrappers"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; /** * Adding a comment to the syntax will become the first @@ -22,16 +22,16 @@ export enum StateEnum { export function stateEnumFromJSON(object: any): StateEnum { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return StateEnum.UNKNOWN; case 2: - case 'ON': + case "ON": return StateEnum.ON; case 3: - case 'OFF': + case "OFF": return StateEnum.OFF; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return StateEnum.UNRECOGNIZED; } @@ -40,14 +40,14 @@ export function stateEnumFromJSON(object: any): StateEnum { export function stateEnumToJSON(object: StateEnum): string { switch (object) { case StateEnum.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case StateEnum.ON: - return 'ON'; + return "ON"; case StateEnum.OFF: - return 'OFF'; + return "OFF"; case StateEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -84,16 +84,16 @@ export enum Child_Type { export function child_TypeFromJSON(object: any): Child_Type { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return Child_Type.UNKNOWN; case 1: - case 'GOOD': + case "GOOD": return Child_Type.GOOD; case 2: - case 'BAD': + case "BAD": return Child_Type.BAD; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return Child_Type.UNRECOGNIZED; } @@ -102,14 +102,14 @@ export function child_TypeFromJSON(object: any): Child_Type { export function child_TypeToJSON(object: Child_Type): string { switch (object) { case Child_Type.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case Child_Type.GOOD: - return 'GOOD'; + return "GOOD"; case Child_Type.BAD: - return 'BAD'; + return "BAD"; case Child_Type.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -129,16 +129,16 @@ export enum Nested_InnerEnum { export function nested_InnerEnumFromJSON(object: any): Nested_InnerEnum { switch (object) { case 0: - case 'UNKNOWN_INNER': + case "UNKNOWN_INNER": return Nested_InnerEnum.UNKNOWN_INNER; case 100: - case 'GOOD': + case "GOOD": return Nested_InnerEnum.GOOD; case 1000: - case 'BAD': + case "BAD": return Nested_InnerEnum.BAD; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return Nested_InnerEnum.UNRECOGNIZED; } @@ -147,14 +147,14 @@ export function nested_InnerEnumFromJSON(object: any): Nested_InnerEnum { export function nested_InnerEnumToJSON(object: Nested_InnerEnum): string { switch (object) { case Nested_InnerEnum.UNKNOWN_INNER: - return 'UNKNOWN_INNER'; + return "UNKNOWN_INNER"; case Nested_InnerEnum.GOOD: - return 'GOOD'; + return "GOOD"; case Nested_InnerEnum.BAD: - return 'BAD'; + return "BAD"; case Nested_InnerEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -240,7 +240,7 @@ export interface Numbers { function createBaseSimple(): Simple { return { - name: '', + name: "", age: 0, createdAt: undefined, child: undefined, @@ -255,7 +255,7 @@ function createBaseSimple(): Simple { export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== 0) { @@ -353,7 +353,7 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, @@ -376,7 +376,7 @@ export const Simple = { message.child !== undefined && (obj.child = message.child ? Child.toJSON(message.child) : undefined); message.state !== undefined && (obj.state = stateEnumToJSON(message.state)); if (message.grandChildren) { - obj.grandChildren = message.grandChildren.map((e) => (e ? Child.toJSON(e) : undefined)); + obj.grandChildren = message.grandChildren.map((e) => e ? Child.toJSON(e) : undefined); } else { obj.grandChildren = []; } @@ -401,28 +401,29 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.age = object.age ?? 0; message.createdAt = object.createdAt ?? undefined; - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; message.state = object.state ?? 0; message.grandChildren = object.grandChildren?.map((e) => Child.fromPartial(e)) || []; message.coins = object.coins?.map((e) => e) || []; message.snacks = object.snacks?.map((e) => e) || []; message.oldStates = object.oldStates?.map((e) => e) || []; - message.thing = - object.thing !== undefined && object.thing !== null ? ImportedThing.fromPartial(object.thing) : undefined; + message.thing = (object.thing !== undefined && object.thing !== null) + ? ImportedThing.fromPartial(object.thing) + : undefined; return message; }, }; function createBaseChild(): Child { - return { name: '', type: 0 }; + return { name: "", type: 0 }; } export const Child = { encode(message: Child, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.type !== 0) { @@ -454,7 +455,7 @@ export const Child = { fromJSON(object: any): Child { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", type: isSet(object.type) ? child_TypeFromJSON(object.type) : 0, }; }, @@ -468,19 +469,19 @@ export const Child = { fromPartial, I>>(object: I): Child { const message = createBaseChild(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.type = object.type ?? 0; return message; }, }; function createBaseNested(): Nested { - return { name: '', message: undefined, state: 0 }; + return { name: "", message: undefined, state: 0 }; } export const Nested = { encode(message: Nested, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.message !== undefined) { @@ -518,7 +519,7 @@ export const Nested = { fromJSON(object: any): Nested { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", message: isSet(object.message) ? Nested_InnerMessage.fromJSON(object.message) : undefined, state: isSet(object.state) ? nested_InnerEnumFromJSON(object.state) : 0, }; @@ -535,23 +536,22 @@ export const Nested = { fromPartial, I>>(object: I): Nested { const message = createBaseNested(); - message.name = object.name ?? ''; - message.message = - object.message !== undefined && object.message !== null - ? Nested_InnerMessage.fromPartial(object.message) - : undefined; + message.name = object.name ?? ""; + message.message = (object.message !== undefined && object.message !== null) + ? Nested_InnerMessage.fromPartial(object.message) + : undefined; message.state = object.state ?? 0; return message; }, }; function createBaseNested_InnerMessage(): Nested_InnerMessage { - return { name: '', deep: undefined }; + return { name: "", deep: undefined }; } export const Nested_InnerMessage = { encode(message: Nested_InnerMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.deep !== undefined) { @@ -583,7 +583,7 @@ export const Nested_InnerMessage = { fromJSON(object: any): Nested_InnerMessage { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", deep: isSet(object.deep) ? Nested_InnerMessage_DeepMessage.fromJSON(object.deep) : undefined, }; }, @@ -598,22 +598,21 @@ export const Nested_InnerMessage = { fromPartial, I>>(object: I): Nested_InnerMessage { const message = createBaseNested_InnerMessage(); - message.name = object.name ?? ''; - message.deep = - object.deep !== undefined && object.deep !== null - ? Nested_InnerMessage_DeepMessage.fromPartial(object.deep) - : undefined; + message.name = object.name ?? ""; + message.deep = (object.deep !== undefined && object.deep !== null) + ? Nested_InnerMessage_DeepMessage.fromPartial(object.deep) + : undefined; return message; }, }; function createBaseNested_InnerMessage_DeepMessage(): Nested_InnerMessage_DeepMessage { - return { name: '' }; + return { name: "" }; } export const Nested_InnerMessage_DeepMessage = { encode(message: Nested_InnerMessage_DeepMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -638,9 +637,7 @@ export const Nested_InnerMessage_DeepMessage = { }, fromJSON(object: any): Nested_InnerMessage_DeepMessage { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Nested_InnerMessage_DeepMessage): unknown { @@ -650,10 +647,10 @@ export const Nested_InnerMessage_DeepMessage = { }, fromPartial, I>>( - object: I + object: I, ): Nested_InnerMessage_DeepMessage { const message = createBaseNested_InnerMessage_DeepMessage(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; @@ -840,9 +837,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { - id: isSet(object.id) ? Number(object.id) : 0, - }; + return { id: isSet(object.id) ? Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -913,21 +908,21 @@ export const SimpleWithMap = { return { entitiesById: isObject(object.entitiesById) ? Object.entries(object.entitiesById).reduce<{ [key: number]: Entity }>((acc, [key, value]) => { - acc[Number(key)] = Entity.fromJSON(value); - return acc; - }, {}) + acc[Number(key)] = Entity.fromJSON(value); + return acc; + }, {}) : {}, nameLookup: isObject(object.nameLookup) ? Object.entries(object.nameLookup).reduce<{ [key: string]: string }>((acc, [key, value]) => { - acc[key] = String(value); - return acc; - }, {}) + acc[key] = String(value); + return acc; + }, {}) : {}, intLookup: isObject(object.intLookup) ? Object.entries(object.intLookup).reduce<{ [key: number]: number }>((acc, [key, value]) => { - acc[Number(key)] = Number(value); - return acc; - }, {}) + acc[Number(key)] = Number(value); + return acc; + }, {}) : {}, }; }, @@ -964,7 +959,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { @@ -973,7 +968,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { @@ -982,7 +977,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); return message; }, @@ -1039,25 +1034,27 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_EntitiesByIdEntry { const message = createBaseSimpleWithMap_EntitiesByIdEntry(); message.key = object.key ?? 0; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; function createBaseSimpleWithMap_NameLookupEntry(): SimpleWithMap_NameLookupEntry { - return { key: '', value: '' }; + return { key: "", value: "" }; } export const SimpleWithMap_NameLookupEntry = { encode(message: SimpleWithMap_NameLookupEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -1085,10 +1082,7 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object.value) ? String(object.value) : '', - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -1099,11 +1093,11 @@ export const SimpleWithMap_NameLookupEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_NameLookupEntry { const message = createBaseSimpleWithMap_NameLookupEntry(); - message.key = object.key ?? ''; - message.value = object.value ?? ''; + message.key = object.key ?? ""; + message.value = object.value ?? ""; return message; }, }; @@ -1145,10 +1139,7 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { - key: isSet(object.key) ? Number(object.key) : 0, - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -1203,9 +1194,9 @@ export const SimpleWithSnakeCaseMap = { return { entitiesById: isObject(object.entitiesById) ? Object.entries(object.entitiesById).reduce<{ [key: number]: Entity }>((acc, [key, value]) => { - acc[Number(key)] = Entity.fromJSON(value); - return acc; - }, {}) + acc[Number(key)] = Entity.fromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -1230,7 +1221,7 @@ export const SimpleWithSnakeCaseMap = { } return acc; }, - {} + {}, ); return message; }, @@ -1287,22 +1278,24 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithSnakeCaseMap_EntitiesByIdEntry { const message = createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(); message.key = object.key ?? 0; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; function createBasePingRequest(): PingRequest { - return { input: '' }; + return { input: "" }; } export const PingRequest = { encode(message: PingRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.input !== '') { + if (message.input !== "") { writer.uint32(10).string(message.input); } return writer; @@ -1327,9 +1320,7 @@ export const PingRequest = { }, fromJSON(object: any): PingRequest { - return { - input: isSet(object.input) ? String(object.input) : '', - }; + return { input: isSet(object.input) ? String(object.input) : "" }; }, toJSON(message: PingRequest): unknown { @@ -1340,18 +1331,18 @@ export const PingRequest = { fromPartial, I>>(object: I): PingRequest { const message = createBasePingRequest(); - message.input = object.input ?? ''; + message.input = object.input ?? ""; return message; }, }; function createBasePingResponse(): PingResponse { - return { output: '' }; + return { output: "" }; } export const PingResponse = { encode(message: PingResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.output !== '') { + if (message.output !== "") { writer.uint32(10).string(message.output); } return writer; @@ -1376,9 +1367,7 @@ export const PingResponse = { }, fromJSON(object: any): PingResponse { - return { - output: isSet(object.output) ? String(object.output) : '', - }; + return { output: isSet(object.output) ? String(object.output) : "" }; }, toJSON(message: PingResponse): unknown { @@ -1389,7 +1378,7 @@ export const PingResponse = { fromPartial, I>>(object: I): PingResponse { const message = createBasePingResponse(); - message.output = object.output ?? ''; + message.output = object.output ?? ""; return message; }, }; @@ -1567,7 +1556,7 @@ export class PingServiceClientImpl implements PingService { } ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); - const promise = this.rpc.request('simple.PingService', 'ping', data); + const promise = this.rpc.request("simple.PingService", "ping", data); return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); } } @@ -1580,28 +1569,30 @@ 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'; + 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -1619,7 +1610,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); @@ -1628,7 +1619,7 @@ function fromJsonTimestamp(o: any): Date { function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } @@ -1641,7 +1632,7 @@ if (_m0.util.Long !== Long) { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/simple-optionals/thing.ts b/integration/simple-optionals/thing.ts index 5f90a8fc5..4c23af81c 100644 --- a/integration/simple-optionals/thing.ts +++ b/integration/simple-optionals/thing.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { Timestamp } from './google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface ImportedThing { createdAt?: Date; @@ -39,9 +39,7 @@ export const ImportedThing = { }, fromJSON(object: any): ImportedThing { - return { - createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, - }; + return { createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined }; }, toJSON(message: ImportedThing): unknown { @@ -59,19 +57,13 @@ export const ImportedThing = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -89,7 +81,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/simple-proto2/simple.ts b/integration/simple-proto2/simple.ts index f186d8db4..baaf5c1c3 100644 --- a/integration/simple-proto2/simple.ts +++ b/integration/simple-proto2/simple.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export enum EnumWithoutZero { A = 1, @@ -12,13 +12,13 @@ export enum EnumWithoutZero { export function enumWithoutZeroFromJSON(object: any): EnumWithoutZero { switch (object) { case 1: - case 'A': + case "A": return EnumWithoutZero.A; case 2: - case 'B': + case "B": return EnumWithoutZero.B; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return EnumWithoutZero.UNRECOGNIZED; } @@ -27,12 +27,12 @@ export function enumWithoutZeroFromJSON(object: any): EnumWithoutZero { export function enumWithoutZeroToJSON(object: EnumWithoutZero): string { switch (object) { case EnumWithoutZero.A: - return 'A'; + return "A"; case EnumWithoutZero.B: - return 'B'; + return "B"; case EnumWithoutZero.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -71,9 +71,7 @@ export const Issue56 = { }, fromJSON(object: any): Issue56 { - return { - test: isSet(object.test) ? enumWithoutZeroFromJSON(object.test) : 1, - }; + return { test: isSet(object.test) ? enumWithoutZeroFromJSON(object.test) : 1 }; }, toJSON(message: Issue56): unknown { @@ -91,19 +89,13 @@ export const Issue56 = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/simple-prototype-defaults/google/protobuf/timestamp.ts b/integration/simple-prototype-defaults/google/protobuf/timestamp.ts index 318705b86..fb745da37 100644 --- a/integration/simple-prototype-defaults/google/protobuf/timestamp.ts +++ b/integration/simple-prototype-defaults/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple-prototype-defaults/google/protobuf/wrappers.ts b/integration/simple-prototype-defaults/google/protobuf/wrappers.ts index 75c5fa0c4..e6fb1977d 100644 --- a/integration/simple-prototype-defaults/google/protobuf/wrappers.ts +++ b/integration/simple-prototype-defaults/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial, I>>(object: I): StringValue { const message = Object.create(createBaseStringValue()) as StringValue; - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), - }; + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,36 +552,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple-prototype-defaults/google/type/date.ts b/integration/simple-prototype-defaults/google/type/date.ts index 8ffe102fc..88370d856 100644 --- a/integration/simple-prototype-defaults/google/type/date.ts +++ b/integration/simple-prototype-defaults/google/type/date.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.type'; +export const protobufPackage = "google.type"; /** * Represents a whole or partial calendar date, e.g. a birthday. The time of day @@ -103,19 +103,13 @@ export const DateMessage = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/simple-prototype-defaults/import_dir/thing.ts b/integration/simple-prototype-defaults/import_dir/thing.ts index 9343a8982..627f63fe6 100644 --- a/integration/simple-prototype-defaults/import_dir/thing.ts +++ b/integration/simple-prototype-defaults/import_dir/thing.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { Timestamp } from '../google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; +import { Timestamp } from "../google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface ImportedThing { createdAt: Date | undefined; @@ -39,9 +39,7 @@ export const ImportedThing = { }, fromJSON(object: any): ImportedThing { - return { - createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, - }; + return { createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined }; }, toJSON(message: ImportedThing): unknown { @@ -59,19 +57,13 @@ export const ImportedThing = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -89,7 +81,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/simple-prototype-defaults/simple.ts b/integration/simple-prototype-defaults/simple.ts index 37511aad4..75641dc53 100644 --- a/integration/simple-prototype-defaults/simple.ts +++ b/integration/simple-prototype-defaults/simple.ts @@ -1,12 +1,12 @@ /* eslint-disable */ -import { Timestamp } from './google/protobuf/timestamp'; -import * as Long from 'long'; -import { ImportedThing } from './import_dir/thing'; -import { DateMessage } from './google/type/date'; -import * as _m0 from 'protobufjs/minimal'; -import { StringValue, Int32Value, BoolValue, BytesValue } from './google/protobuf/wrappers'; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as Long from "long"; +import { ImportedThing } from "./import_dir/thing"; +import { DateMessage } from "./google/type/date"; +import * as _m0 from "protobufjs/minimal"; +import { BoolValue, BytesValue, Int32Value, StringValue } from "./google/protobuf/wrappers"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; /** * Adding a comment to the syntax will become the first @@ -23,16 +23,16 @@ export enum StateEnum { export function stateEnumFromJSON(object: any): StateEnum { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return StateEnum.UNKNOWN; case 2: - case 'ON': + case "ON": return StateEnum.ON; case 3: - case 'OFF': + case "OFF": return StateEnum.OFF; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return StateEnum.UNRECOGNIZED; } @@ -41,14 +41,14 @@ export function stateEnumFromJSON(object: any): StateEnum { export function stateEnumToJSON(object: StateEnum): string { switch (object) { case StateEnum.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case StateEnum.ON: - return 'ON'; + return "ON"; case StateEnum.OFF: - return 'OFF'; + return "OFF"; case StateEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -88,16 +88,16 @@ export enum Child_Type { export function child_TypeFromJSON(object: any): Child_Type { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return Child_Type.UNKNOWN; case 1: - case 'GOOD': + case "GOOD": return Child_Type.GOOD; case 2: - case 'BAD': + case "BAD": return Child_Type.BAD; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return Child_Type.UNRECOGNIZED; } @@ -106,14 +106,14 @@ export function child_TypeFromJSON(object: any): Child_Type { export function child_TypeToJSON(object: Child_Type): string { switch (object) { case Child_Type.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case Child_Type.GOOD: - return 'GOOD'; + return "GOOD"; case Child_Type.BAD: - return 'BAD'; + return "BAD"; case Child_Type.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -133,16 +133,16 @@ export enum Nested_InnerEnum { export function nested_InnerEnumFromJSON(object: any): Nested_InnerEnum { switch (object) { case 0: - case 'UNKNOWN_INNER': + case "UNKNOWN_INNER": return Nested_InnerEnum.UNKNOWN_INNER; case 100: - case 'GOOD': + case "GOOD": return Nested_InnerEnum.GOOD; case 1000: - case 'BAD': + case "BAD": return Nested_InnerEnum.BAD; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return Nested_InnerEnum.UNRECOGNIZED; } @@ -151,14 +151,14 @@ export function nested_InnerEnumFromJSON(object: any): Nested_InnerEnum { export function nested_InnerEnumToJSON(object: Nested_InnerEnum): string { switch (object) { case Nested_InnerEnum.UNKNOWN_INNER: - return 'UNKNOWN_INNER'; + return "UNKNOWN_INNER"; case Nested_InnerEnum.GOOD: - return 'GOOD'; + return "GOOD"; case Nested_InnerEnum.BAD: - return 'BAD'; + return "BAD"; case Nested_InnerEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -279,23 +279,30 @@ export interface Numbers { /** For testing proto3's field presence feature. */ export interface SimpleButOptional { /** Name field */ - name?: string | undefined; + name?: + | string + | undefined; /** Age */ - age?: number | undefined; + age?: + | number + | undefined; /** This comment will also attach */ createdAt?: Date | undefined; child?: Child | undefined; - state?: StateEnum | undefined; + state?: + | StateEnum + | undefined; /** A thing (imported from thing) */ thing?: ImportedThing | undefined; birthday?: DateMessage | undefined; } -export interface Empty {} +export interface Empty { +} function createBaseSimple(): Simple { return { - name: '', + name: "", age: 0, createdAt: undefined, child: undefined, @@ -313,7 +320,7 @@ function createBaseSimple(): Simple { export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== 0) { @@ -429,7 +436,7 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, @@ -455,7 +462,7 @@ export const Simple = { message.child !== undefined && (obj.child = message.child ? Child.toJSON(message.child) : undefined); message.state !== undefined && (obj.state = stateEnumToJSON(message.state)); if (message.grandChildren) { - obj.grandChildren = message.grandChildren.map((e) => (e ? Child.toJSON(e) : undefined)); + obj.grandChildren = message.grandChildren.map((e) => e ? Child.toJSON(e) : undefined); } else { obj.grandChildren = []; } @@ -489,32 +496,34 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = Object.create(createBaseSimple()) as Simple; - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.age = object.age ?? 0; message.createdAt = object.createdAt ?? undefined; - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; message.state = object.state ?? 0; message.grandChildren = object.grandChildren?.map((e) => Child.fromPartial(e)) || []; message.coins = object.coins?.map((e) => e) || []; message.snacks = object.snacks?.map((e) => e) || []; message.oldStates = object.oldStates?.map((e) => e) || []; - message.thing = - object.thing !== undefined && object.thing !== null ? ImportedThing.fromPartial(object.thing) : undefined; + message.thing = (object.thing !== undefined && object.thing !== null) + ? ImportedThing.fromPartial(object.thing) + : undefined; message.blobs = object.blobs?.map((e) => e) || []; - message.birthday = - object.birthday !== undefined && object.birthday !== null ? DateMessage.fromPartial(object.birthday) : undefined; + message.birthday = (object.birthday !== undefined && object.birthday !== null) + ? DateMessage.fromPartial(object.birthday) + : undefined; message.blob = object.blob ?? new Uint8Array(); return message; }, }; function createBaseChild(): Child { - return { name: '', type: 0 }; + return { name: "", type: 0 }; } export const Child = { encode(message: Child, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.type !== 0) { @@ -546,7 +555,7 @@ export const Child = { fromJSON(object: any): Child { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", type: isSet(object.type) ? child_TypeFromJSON(object.type) : 0, }; }, @@ -560,19 +569,19 @@ export const Child = { fromPartial, I>>(object: I): Child { const message = Object.create(createBaseChild()) as Child; - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.type = object.type ?? 0; return message; }, }; function createBaseNested(): Nested { - return { name: '', message: undefined, state: 0 }; + return { name: "", message: undefined, state: 0 }; } export const Nested = { encode(message: Nested, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.message !== undefined) { @@ -610,7 +619,7 @@ export const Nested = { fromJSON(object: any): Nested { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", message: isSet(object.message) ? Nested_InnerMessage.fromJSON(object.message) : undefined, state: isSet(object.state) ? nested_InnerEnumFromJSON(object.state) : 0, }; @@ -627,23 +636,22 @@ export const Nested = { fromPartial, I>>(object: I): Nested { const message = Object.create(createBaseNested()) as Nested; - message.name = object.name ?? ''; - message.message = - object.message !== undefined && object.message !== null - ? Nested_InnerMessage.fromPartial(object.message) - : undefined; + message.name = object.name ?? ""; + message.message = (object.message !== undefined && object.message !== null) + ? Nested_InnerMessage.fromPartial(object.message) + : undefined; message.state = object.state ?? 0; return message; }, }; function createBaseNested_InnerMessage(): Nested_InnerMessage { - return { name: '', deep: undefined }; + return { name: "", deep: undefined }; } export const Nested_InnerMessage = { encode(message: Nested_InnerMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.deep !== undefined) { @@ -675,7 +683,7 @@ export const Nested_InnerMessage = { fromJSON(object: any): Nested_InnerMessage { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", deep: isSet(object.deep) ? Nested_InnerMessage_DeepMessage.fromJSON(object.deep) : undefined, }; }, @@ -690,22 +698,21 @@ export const Nested_InnerMessage = { fromPartial, I>>(object: I): Nested_InnerMessage { const message = Object.create(createBaseNested_InnerMessage()) as Nested_InnerMessage; - message.name = object.name ?? ''; - message.deep = - object.deep !== undefined && object.deep !== null - ? Nested_InnerMessage_DeepMessage.fromPartial(object.deep) - : undefined; + message.name = object.name ?? ""; + message.deep = (object.deep !== undefined && object.deep !== null) + ? Nested_InnerMessage_DeepMessage.fromPartial(object.deep) + : undefined; return message; }, }; function createBaseNested_InnerMessage_DeepMessage(): Nested_InnerMessage_DeepMessage { - return { name: '' }; + return { name: "" }; } export const Nested_InnerMessage_DeepMessage = { encode(message: Nested_InnerMessage_DeepMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -730,9 +737,7 @@ export const Nested_InnerMessage_DeepMessage = { }, fromJSON(object: any): Nested_InnerMessage_DeepMessage { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Nested_InnerMessage_DeepMessage): unknown { @@ -742,10 +747,10 @@ export const Nested_InnerMessage_DeepMessage = { }, fromPartial, I>>( - object: I + object: I, ): Nested_InnerMessage_DeepMessage { const message = Object.create(createBaseNested_InnerMessage_DeepMessage()) as Nested_InnerMessage_DeepMessage; - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; @@ -941,9 +946,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { - id: isSet(object.id) ? Number(object.id) : 0, - }; + return { id: isSet(object.id) ? Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -1060,48 +1063,48 @@ export const SimpleWithMap = { return { entitiesById: isObject(object.entitiesById) ? Object.entries(object.entitiesById).reduce<{ [key: number]: Entity }>((acc, [key, value]) => { - acc[Number(key)] = Entity.fromJSON(value); - return acc; - }, {}) + acc[Number(key)] = Entity.fromJSON(value); + return acc; + }, {}) : {}, nameLookup: isObject(object.nameLookup) ? Object.entries(object.nameLookup).reduce<{ [key: string]: string }>((acc, [key, value]) => { - acc[key] = String(value); - return acc; - }, {}) + acc[key] = String(value); + return acc; + }, {}) : {}, intLookup: isObject(object.intLookup) ? Object.entries(object.intLookup).reduce<{ [key: number]: number }>((acc, [key, value]) => { - acc[Number(key)] = Number(value); - return acc; - }, {}) + acc[Number(key)] = Number(value); + return acc; + }, {}) : {}, mapOfTimestamps: isObject(object.mapOfTimestamps) ? Object.entries(object.mapOfTimestamps).reduce<{ [key: string]: Date }>((acc, [key, value]) => { - acc[key] = fromJsonTimestamp(value); - return acc; - }, {}) + acc[key] = fromJsonTimestamp(value); + return acc; + }, {}) : {}, mapOfBytes: isObject(object.mapOfBytes) ? Object.entries(object.mapOfBytes).reduce<{ [key: string]: Uint8Array }>((acc, [key, value]) => { - acc[key] = bytesFromBase64(value as string); - return acc; - }, {}) + acc[key] = bytesFromBase64(value as string); + return acc; + }, {}) : {}, mapOfStringValues: isObject(object.mapOfStringValues) ? Object.entries(object.mapOfStringValues).reduce<{ [key: string]: string | undefined }>( - (acc, [key, value]) => { - acc[key] = value as string | undefined; - return acc; - }, - {} - ) + (acc, [key, value]) => { + acc[key] = value as string | undefined; + return acc; + }, + {}, + ) : {}, longLookup: isObject(object.longLookup) ? Object.entries(object.longLookup).reduce<{ [key: number]: number }>((acc, [key, value]) => { - acc[Number(key)] = Number(value); - return acc; - }, {}) + acc[Number(key)] = Number(value); + return acc; + }, {}) : {}, }; }, @@ -1162,7 +1165,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { @@ -1171,7 +1174,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { @@ -1180,7 +1183,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.mapOfTimestamps = Object.entries(object.mapOfTimestamps ?? {}).reduce<{ [key: string]: Date }>( (acc, [key, value]) => { @@ -1189,7 +1192,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.mapOfBytes = Object.entries(object.mapOfBytes ?? {}).reduce<{ [key: string]: Uint8Array }>( (acc, [key, value]) => { @@ -1198,11 +1201,11 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); - message.mapOfStringValues = Object.entries(object.mapOfStringValues ?? {}).reduce<{ - [key: string]: string | undefined; - }>((acc, [key, value]) => { + message.mapOfStringValues = Object.entries(object.mapOfStringValues ?? {}).reduce< + { [key: string]: string | undefined } + >((acc, [key, value]) => { if (value !== undefined) { acc[key] = value; } @@ -1215,7 +1218,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); return message; }, @@ -1272,25 +1275,27 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_EntitiesByIdEntry { const message = Object.create(createBaseSimpleWithMap_EntitiesByIdEntry()) as SimpleWithMap_EntitiesByIdEntry; message.key = object.key ?? 0; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; function createBaseSimpleWithMap_NameLookupEntry(): SimpleWithMap_NameLookupEntry { - return { key: '', value: '' }; + return { key: "", value: "" }; } export const SimpleWithMap_NameLookupEntry = { encode(message: SimpleWithMap_NameLookupEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -1318,10 +1323,7 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object.value) ? String(object.value) : '', - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -1332,11 +1334,11 @@ export const SimpleWithMap_NameLookupEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_NameLookupEntry { const message = Object.create(createBaseSimpleWithMap_NameLookupEntry()) as SimpleWithMap_NameLookupEntry; - message.key = object.key ?? ''; - message.value = object.value ?? ''; + message.key = object.key ?? ""; + message.value = object.value ?? ""; return message; }, }; @@ -1378,10 +1380,7 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { - key: isSet(object.key) ? Number(object.key) : 0, - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -1400,12 +1399,12 @@ export const SimpleWithMap_IntLookupEntry = { }; function createBaseSimpleWithMap_MapOfTimestampsEntry(): SimpleWithMap_MapOfTimestampsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const SimpleWithMap_MapOfTimestampsEntry = { encode(message: SimpleWithMap_MapOfTimestampsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -1437,7 +1436,7 @@ export const SimpleWithMap_MapOfTimestampsEntry = { fromJSON(object: any): SimpleWithMap_MapOfTimestampsEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? fromJsonTimestamp(object.value) : undefined, }; }, @@ -1450,22 +1449,22 @@ export const SimpleWithMap_MapOfTimestampsEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_MapOfTimestampsEntry { const message = Object.create(createBaseSimpleWithMap_MapOfTimestampsEntry()) as SimpleWithMap_MapOfTimestampsEntry; - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, }; function createBaseSimpleWithMap_MapOfBytesEntry(): SimpleWithMap_MapOfBytesEntry { - return { key: '', value: new Uint8Array() }; + return { key: "", value: new Uint8Array() }; } export const SimpleWithMap_MapOfBytesEntry = { encode(message: SimpleWithMap_MapOfBytesEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value.length !== 0) { @@ -1497,7 +1496,7 @@ export const SimpleWithMap_MapOfBytesEntry = { fromJSON(object: any): SimpleWithMap_MapOfBytesEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), }; }, @@ -1511,22 +1510,22 @@ export const SimpleWithMap_MapOfBytesEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_MapOfBytesEntry { const message = Object.create(createBaseSimpleWithMap_MapOfBytesEntry()) as SimpleWithMap_MapOfBytesEntry; - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? new Uint8Array(); return message; }, }; function createBaseSimpleWithMap_MapOfStringValuesEntry(): SimpleWithMap_MapOfStringValuesEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const SimpleWithMap_MapOfStringValuesEntry = { encode(message: SimpleWithMap_MapOfStringValuesEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -1539,7 +1538,7 @@ export const SimpleWithMap_MapOfStringValuesEntry = { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create( - createBaseSimpleWithMap_MapOfStringValuesEntry() + createBaseSimpleWithMap_MapOfStringValuesEntry(), ) as SimpleWithMap_MapOfStringValuesEntry; while (reader.pos < end) { const tag = reader.uint32(); @@ -1560,7 +1559,7 @@ export const SimpleWithMap_MapOfStringValuesEntry = { fromJSON(object: any): SimpleWithMap_MapOfStringValuesEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : undefined, }; }, @@ -1573,12 +1572,12 @@ export const SimpleWithMap_MapOfStringValuesEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_MapOfStringValuesEntry { const message = Object.create( - createBaseSimpleWithMap_MapOfStringValuesEntry() + createBaseSimpleWithMap_MapOfStringValuesEntry(), ) as SimpleWithMap_MapOfStringValuesEntry; - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -1621,10 +1620,7 @@ export const SimpleWithMap_LongLookupEntry = { }, fromJSON(object: any): SimpleWithMap_LongLookupEntry { - return { - key: isSet(object.key) ? Number(object.key) : 0, - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: SimpleWithMap_LongLookupEntry): unknown { @@ -1635,7 +1631,7 @@ export const SimpleWithMap_LongLookupEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_LongLookupEntry { const message = Object.create(createBaseSimpleWithMap_LongLookupEntry()) as SimpleWithMap_LongLookupEntry; message.key = object.key ?? 0; @@ -1681,9 +1677,9 @@ export const SimpleWithSnakeCaseMap = { return { entitiesById: isObject(object.entitiesById) ? Object.entries(object.entitiesById).reduce<{ [key: number]: Entity }>((acc, [key, value]) => { - acc[Number(key)] = Entity.fromJSON(value); - return acc; - }, {}) + acc[Number(key)] = Entity.fromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -1708,7 +1704,7 @@ export const SimpleWithSnakeCaseMap = { } return acc; }, - {} + {}, ); return message; }, @@ -1733,7 +1729,7 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create( - createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry() + createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(), ) as SimpleWithSnakeCaseMap_EntitiesByIdEntry; while (reader.pos < end) { const tag = reader.uint32(); @@ -1767,13 +1763,15 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithSnakeCaseMap_EntitiesByIdEntry { const message = Object.create( - createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry() + createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(), ) as SimpleWithSnakeCaseMap_EntitiesByIdEntry; message.key = object.key ?? 0; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; @@ -1815,9 +1813,9 @@ export const SimpleWithMapOfEnums = { return { enumsById: isObject(object.enumsById) ? Object.entries(object.enumsById).reduce<{ [key: number]: StateEnum }>((acc, [key, value]) => { - acc[Number(key)] = stateEnumFromJSON(value); - return acc; - }, {}) + acc[Number(key)] = stateEnumFromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -1842,7 +1840,7 @@ export const SimpleWithMapOfEnums = { } return acc; }, - {} + {}, ); return message; }, @@ -1867,7 +1865,7 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = Object.create( - createBaseSimpleWithMapOfEnums_EnumsByIdEntry() + createBaseSimpleWithMapOfEnums_EnumsByIdEntry(), ) as SimpleWithMapOfEnums_EnumsByIdEntry; while (reader.pos < end) { const tag = reader.uint32(); @@ -1901,10 +1899,10 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMapOfEnums_EnumsByIdEntry { const message = Object.create( - createBaseSimpleWithMapOfEnums_EnumsByIdEntry() + createBaseSimpleWithMapOfEnums_EnumsByIdEntry(), ) as SimpleWithMapOfEnums_EnumsByIdEntry; message.key = object.key ?? 0; message.value = object.value ?? 0; @@ -1913,12 +1911,12 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { }; function createBasePingRequest(): PingRequest { - return { input: '' }; + return { input: "" }; } export const PingRequest = { encode(message: PingRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.input !== '') { + if (message.input !== "") { writer.uint32(10).string(message.input); } return writer; @@ -1943,9 +1941,7 @@ export const PingRequest = { }, fromJSON(object: any): PingRequest { - return { - input: isSet(object.input) ? String(object.input) : '', - }; + return { input: isSet(object.input) ? String(object.input) : "" }; }, toJSON(message: PingRequest): unknown { @@ -1956,18 +1952,18 @@ export const PingRequest = { fromPartial, I>>(object: I): PingRequest { const message = Object.create(createBasePingRequest()) as PingRequest; - message.input = object.input ?? ''; + message.input = object.input ?? ""; return message; }, }; function createBasePingResponse(): PingResponse { - return { output: '' }; + return { output: "" }; } export const PingResponse = { encode(message: PingResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.output !== '') { + if (message.output !== "") { writer.uint32(10).string(message.output); } return writer; @@ -1992,9 +1988,7 @@ export const PingResponse = { }, fromJSON(object: any): PingResponse { - return { - output: isSet(object.output) ? String(object.output) : '', - }; + return { output: isSet(object.output) ? String(object.output) : "" }; }, toJSON(message: PingResponse): unknown { @@ -2005,7 +1999,7 @@ export const PingResponse = { fromPartial, I>>(object: I): PingResponse { const message = Object.create(createBasePingResponse()) as PingResponse; - message.output = object.output ?? ''; + message.output = object.output ?? ""; return message; }, }; @@ -2276,12 +2270,14 @@ export const SimpleButOptional = { message.name = object.name ?? undefined; message.age = object.age ?? undefined; message.createdAt = object.createdAt ?? undefined; - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; message.state = object.state ?? undefined; - message.thing = - object.thing !== undefined && object.thing !== null ? ImportedThing.fromPartial(object.thing) : undefined; - message.birthday = - object.birthday !== undefined && object.birthday !== null ? DateMessage.fromPartial(object.birthday) : undefined; + message.thing = (object.thing !== undefined && object.thing !== null) + ? ImportedThing.fromPartial(object.thing) + : undefined; + message.birthday = (object.birthday !== undefined && object.birthday !== null) + ? DateMessage.fromPartial(object.birthday) + : undefined; return message; }, }; @@ -2337,7 +2333,7 @@ export class PingServiceClientImpl implements PingService { } ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); - const promise = this.rpc.request('simple.PingService', 'ping', data); + const promise = this.rpc.request("simple.PingService", "ping", data); return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); } } @@ -2350,16 +2346,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -2372,31 +2376,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -2414,7 +2412,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); @@ -2423,7 +2421,7 @@ function fromJsonTimestamp(o: any): Date { function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } @@ -2436,7 +2434,7 @@ if (_m0.util.Long !== Long) { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/simple-snake/google/protobuf/struct.ts b/integration/simple-snake/google/protobuf/struct.ts index 934647e33..802676863 100644 --- a/integration/simple-snake/google/protobuf/struct.ts +++ b/integration/simple-snake/google/protobuf/struct.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the @@ -18,10 +18,10 @@ export enum NullValue { export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: - case 'NULL_VALUE': + case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } @@ -30,10 +30,10 @@ export function nullValueFromJSON(object: any): NullValue { export function nullValueToJSON(object: NullValue): string { switch (object) { case NullValue.NULL_VALUE: - return 'NULL_VALUE'; + return "NULL_VALUE"; case NullValue.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -67,15 +67,25 @@ export interface Struct_FieldsEntry { */ export interface Value { /** Represents a null value. */ - null_value: NullValue | undefined; + null_value: + | NullValue + | undefined; /** Represents a double value. */ - number_value: number | undefined; + number_value: + | number + | undefined; /** Represents a string value. */ - string_value: string | undefined; + string_value: + | string + | undefined; /** Represents a boolean value. */ - bool_value: boolean | undefined; + bool_value: + | boolean + | undefined; /** Represents a structured value. */ - struct_value: { [key: string]: any } | undefined; + struct_value: + | { [key: string]: any } + | undefined; /** Represents a repeated `Value`. */ list_value: Array | undefined; } @@ -129,9 +139,9 @@ export const 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; - }, {}) + acc[key] = value as any | undefined; + return acc; + }, {}) : {}, }; }, @@ -156,7 +166,7 @@ export const Struct = { } return acc; }, - {} + {}, ); return message; }, @@ -181,12 +191,12 @@ export const Struct = { }; function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Struct_FieldsEntry = { encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -217,10 +227,7 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object?.value) ? object.value : undefined, - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -232,7 +239,7 @@ export const Struct_FieldsEntry = { fromPartial, I>>(object: I): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -344,18 +351,18 @@ export const Value = { if (value === null) { result.null_value = NullValue.NULL_VALUE; - } else if (typeof value === 'boolean') { + } else if (typeof value === "boolean") { result.bool_value = value; - } else if (typeof value === 'number') { + } else if (typeof value === "number") { result.number_value = value; - } else if (typeof value === 'string') { + } else if (typeof value === "string") { result.string_value = value; } else if (Array.isArray(value)) { result.list_value = value; - } else if (typeof value === 'object') { + } else if (typeof value === "object") { result.struct_value = value; - } else if (typeof value !== 'undefined') { - throw new Error('Unsupported any value type: ' + typeof value); + } else if (typeof value !== "undefined") { + throw new Error("Unsupported any value type: " + typeof value); } return result; @@ -410,9 +417,7 @@ export const ListValue = { }, fromJSON(object: any): ListValue { - return { - values: Array.isArray(object?.values) ? [...object.values] : [], - }; + return { values: Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { @@ -446,23 +451,17 @@ export const 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/simple-snake/google/protobuf/timestamp.ts b/integration/simple-snake/google/protobuf/timestamp.ts index c52fb2549..5497f7183 100644 --- a/integration/simple-snake/google/protobuf/timestamp.ts +++ b/integration/simple-snake/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple-snake/google/protobuf/wrappers.ts b/integration/simple-snake/google/protobuf/wrappers.ts index 5e90fd4da..3145298cb 100644 --- a/integration/simple-snake/google/protobuf/wrappers.ts +++ b/integration/simple-snake/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial, I>>(object: I): StringValue { const message = createBaseStringValue(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), - }; + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,36 +552,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple-snake/import_dir/thing.ts b/integration/simple-snake/import_dir/thing.ts index b5e539032..7f66f0584 100644 --- a/integration/simple-snake/import_dir/thing.ts +++ b/integration/simple-snake/import_dir/thing.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { Timestamp } from '../google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; +import { Timestamp } from "../google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface ImportedThing { created_at: Date | undefined; @@ -39,9 +39,7 @@ export const ImportedThing = { }, fromJSON(object: any): ImportedThing { - return { - created_at: isSet(object.created_at) ? fromJsonTimestamp(object.created_at) : undefined, - }; + return { created_at: isSet(object.created_at) ? fromJsonTimestamp(object.created_at) : undefined }; }, toJSON(message: ImportedThing): unknown { @@ -59,19 +57,13 @@ export const ImportedThing = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -89,7 +81,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/simple-snake/simple.ts b/integration/simple-snake/simple.ts index cd86280ee..dbc77664a 100644 --- a/integration/simple-snake/simple.ts +++ b/integration/simple-snake/simple.ts @@ -1,12 +1,12 @@ /* eslint-disable */ -import { Timestamp } from './google/protobuf/timestamp'; -import * as Long from 'long'; -import { ImportedThing } from './import_dir/thing'; -import * as _m0 from 'protobufjs/minimal'; -import { StringValue, Int32Value, BoolValue } from './google/protobuf/wrappers'; -import { Struct } from './google/protobuf/struct'; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as Long from "long"; +import { ImportedThing } from "./import_dir/thing"; +import * as _m0 from "protobufjs/minimal"; +import { BoolValue, Int32Value, StringValue } from "./google/protobuf/wrappers"; +import { Struct } from "./google/protobuf/struct"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; /** * Adding a comment to the syntax will become the first @@ -23,16 +23,16 @@ export enum StateEnum { export function stateEnumFromJSON(object: any): StateEnum { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return StateEnum.UNKNOWN; case 2: - case 'ON': + case "ON": return StateEnum.ON; case 3: - case 'OFF': + case "OFF": return StateEnum.OFF; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return StateEnum.UNRECOGNIZED; } @@ -41,14 +41,14 @@ export function stateEnumFromJSON(object: any): StateEnum { export function stateEnumToJSON(object: StateEnum): string { switch (object) { case StateEnum.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case StateEnum.ON: - return 'ON'; + return "ON"; case StateEnum.OFF: - return 'OFF'; + return "OFF"; case StateEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -85,16 +85,16 @@ export enum Child_Type { export function child_TypeFromJSON(object: any): Child_Type { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return Child_Type.UNKNOWN; case 1: - case 'GOOD': + case "GOOD": return Child_Type.GOOD; case 2: - case 'BAD': + case "BAD": return Child_Type.BAD; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return Child_Type.UNRECOGNIZED; } @@ -103,14 +103,14 @@ export function child_TypeFromJSON(object: any): Child_Type { export function child_TypeToJSON(object: Child_Type): string { switch (object) { case Child_Type.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case Child_Type.GOOD: - return 'GOOD'; + return "GOOD"; case Child_Type.BAD: - return 'BAD'; + return "BAD"; case Child_Type.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -130,16 +130,16 @@ export enum Nested_InnerEnum { export function nested_InnerEnumFromJSON(object: any): Nested_InnerEnum { switch (object) { case 0: - case 'UNKNOWN_INNER': + case "UNKNOWN_INNER": return Nested_InnerEnum.UNKNOWN_INNER; case 100: - case 'GOOD': + case "GOOD": return Nested_InnerEnum.GOOD; case 1000: - case 'BAD': + case "BAD": return Nested_InnerEnum.BAD; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return Nested_InnerEnum.UNRECOGNIZED; } @@ -148,14 +148,14 @@ export function nested_InnerEnumFromJSON(object: any): Nested_InnerEnum { export function nested_InnerEnumToJSON(object: Nested_InnerEnum): string { switch (object) { case Nested_InnerEnum.UNKNOWN_INNER: - return 'UNKNOWN_INNER'; + return "UNKNOWN_INNER"; case Nested_InnerEnum.GOOD: - return 'GOOD'; + return "GOOD"; case Nested_InnerEnum.BAD: - return 'BAD'; + return "BAD"; case Nested_InnerEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -245,7 +245,7 @@ export interface SimpleStruct { function createBaseSimple(): Simple { return { - name: '', + name: "", age: 0, created_at: undefined, child: undefined, @@ -260,7 +260,7 @@ function createBaseSimple(): Simple { export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== 0) { @@ -358,7 +358,7 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0, created_at: isSet(object.created_at) ? fromJsonTimestamp(object.created_at) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, @@ -381,7 +381,7 @@ export const Simple = { message.child !== undefined && (obj.child = message.child ? Child.toJSON(message.child) : undefined); message.state !== undefined && (obj.state = stateEnumToJSON(message.state)); if (message.grand_children) { - obj.grand_children = message.grand_children.map((e) => (e ? Child.toJSON(e) : undefined)); + obj.grand_children = message.grand_children.map((e) => e ? Child.toJSON(e) : undefined); } else { obj.grand_children = []; } @@ -406,28 +406,29 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.age = object.age ?? 0; message.created_at = object.created_at ?? undefined; - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; message.state = object.state ?? 0; message.grand_children = object.grand_children?.map((e) => Child.fromPartial(e)) || []; message.coins = object.coins?.map((e) => e) || []; message.snacks = object.snacks?.map((e) => e) || []; message.old_states = object.old_states?.map((e) => e) || []; - message.thing = - object.thing !== undefined && object.thing !== null ? ImportedThing.fromPartial(object.thing) : undefined; + message.thing = (object.thing !== undefined && object.thing !== null) + ? ImportedThing.fromPartial(object.thing) + : undefined; return message; }, }; function createBaseChild(): Child { - return { name: '', type: 0 }; + return { name: "", type: 0 }; } export const Child = { encode(message: Child, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.type !== 0) { @@ -459,7 +460,7 @@ export const Child = { fromJSON(object: any): Child { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", type: isSet(object.type) ? child_TypeFromJSON(object.type) : 0, }; }, @@ -473,19 +474,19 @@ export const Child = { fromPartial, I>>(object: I): Child { const message = createBaseChild(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.type = object.type ?? 0; return message; }, }; function createBaseNested(): Nested { - return { name: '', message: undefined, state: 0 }; + return { name: "", message: undefined, state: 0 }; } export const Nested = { encode(message: Nested, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.message !== undefined) { @@ -523,7 +524,7 @@ export const Nested = { fromJSON(object: any): Nested { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", message: isSet(object.message) ? Nested_InnerMessage.fromJSON(object.message) : undefined, state: isSet(object.state) ? nested_InnerEnumFromJSON(object.state) : 0, }; @@ -540,23 +541,22 @@ export const Nested = { fromPartial, I>>(object: I): Nested { const message = createBaseNested(); - message.name = object.name ?? ''; - message.message = - object.message !== undefined && object.message !== null - ? Nested_InnerMessage.fromPartial(object.message) - : undefined; + message.name = object.name ?? ""; + message.message = (object.message !== undefined && object.message !== null) + ? Nested_InnerMessage.fromPartial(object.message) + : undefined; message.state = object.state ?? 0; return message; }, }; function createBaseNested_InnerMessage(): Nested_InnerMessage { - return { name: '', deep: undefined }; + return { name: "", deep: undefined }; } export const Nested_InnerMessage = { encode(message: Nested_InnerMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.deep !== undefined) { @@ -588,7 +588,7 @@ export const Nested_InnerMessage = { fromJSON(object: any): Nested_InnerMessage { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", deep: isSet(object.deep) ? Nested_InnerMessage_DeepMessage.fromJSON(object.deep) : undefined, }; }, @@ -603,22 +603,21 @@ export const Nested_InnerMessage = { fromPartial, I>>(object: I): Nested_InnerMessage { const message = createBaseNested_InnerMessage(); - message.name = object.name ?? ''; - message.deep = - object.deep !== undefined && object.deep !== null - ? Nested_InnerMessage_DeepMessage.fromPartial(object.deep) - : undefined; + message.name = object.name ?? ""; + message.deep = (object.deep !== undefined && object.deep !== null) + ? Nested_InnerMessage_DeepMessage.fromPartial(object.deep) + : undefined; return message; }, }; function createBaseNested_InnerMessage_DeepMessage(): Nested_InnerMessage_DeepMessage { - return { name: '' }; + return { name: "" }; } export const Nested_InnerMessage_DeepMessage = { encode(message: Nested_InnerMessage_DeepMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -643,9 +642,7 @@ export const Nested_InnerMessage_DeepMessage = { }, fromJSON(object: any): Nested_InnerMessage_DeepMessage { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Nested_InnerMessage_DeepMessage): unknown { @@ -655,10 +652,10 @@ export const Nested_InnerMessage_DeepMessage = { }, fromPartial, I>>( - object: I + object: I, ): Nested_InnerMessage_DeepMessage { const message = createBaseNested_InnerMessage_DeepMessage(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; @@ -845,9 +842,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { - id: isSet(object.id) ? Number(object.id) : 0, - }; + return { id: isSet(object.id) ? Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -918,21 +913,21 @@ export const SimpleWithMap = { return { entitiesById: isObject(object.entitiesById) ? Object.entries(object.entitiesById).reduce<{ [key: number]: Entity }>((acc, [key, value]) => { - acc[Number(key)] = Entity.fromJSON(value); - return acc; - }, {}) + acc[Number(key)] = Entity.fromJSON(value); + return acc; + }, {}) : {}, nameLookup: isObject(object.nameLookup) ? Object.entries(object.nameLookup).reduce<{ [key: string]: string }>((acc, [key, value]) => { - acc[key] = String(value); - return acc; - }, {}) + acc[key] = String(value); + return acc; + }, {}) : {}, intLookup: isObject(object.intLookup) ? Object.entries(object.intLookup).reduce<{ [key: number]: number }>((acc, [key, value]) => { - acc[Number(key)] = Number(value); - return acc; - }, {}) + acc[Number(key)] = Number(value); + return acc; + }, {}) : {}, }; }, @@ -969,7 +964,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { @@ -978,7 +973,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { @@ -987,7 +982,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); return message; }, @@ -1044,25 +1039,27 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_EntitiesByIdEntry { const message = createBaseSimpleWithMap_EntitiesByIdEntry(); message.key = object.key ?? 0; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; function createBaseSimpleWithMap_NameLookupEntry(): SimpleWithMap_NameLookupEntry { - return { key: '', value: '' }; + return { key: "", value: "" }; } export const SimpleWithMap_NameLookupEntry = { encode(message: SimpleWithMap_NameLookupEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -1090,10 +1087,7 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object.value) ? String(object.value) : '', - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -1104,11 +1098,11 @@ export const SimpleWithMap_NameLookupEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_NameLookupEntry { const message = createBaseSimpleWithMap_NameLookupEntry(); - message.key = object.key ?? ''; - message.value = object.value ?? ''; + message.key = object.key ?? ""; + message.value = object.value ?? ""; return message; }, }; @@ -1150,10 +1144,7 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { - key: isSet(object.key) ? Number(object.key) : 0, - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -1208,9 +1199,9 @@ export const SimpleWithSnakeCaseMap = { return { entities_by_id: isObject(object.entities_by_id) ? Object.entries(object.entities_by_id).reduce<{ [key: number]: Entity }>((acc, [key, value]) => { - acc[Number(key)] = Entity.fromJSON(value); - return acc; - }, {}) + acc[Number(key)] = Entity.fromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -1235,7 +1226,7 @@ export const SimpleWithSnakeCaseMap = { } return acc; }, - {} + {}, ); return message; }, @@ -1292,22 +1283,24 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithSnakeCaseMap_EntitiesByIdEntry { const message = createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(); message.key = object.key ?? 0; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; function createBasePingRequest(): PingRequest { - return { input: '' }; + return { input: "" }; } export const PingRequest = { encode(message: PingRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.input !== '') { + if (message.input !== "") { writer.uint32(10).string(message.input); } return writer; @@ -1332,9 +1325,7 @@ export const PingRequest = { }, fromJSON(object: any): PingRequest { - return { - input: isSet(object.input) ? String(object.input) : '', - }; + return { input: isSet(object.input) ? String(object.input) : "" }; }, toJSON(message: PingRequest): unknown { @@ -1345,18 +1336,18 @@ export const PingRequest = { fromPartial, I>>(object: I): PingRequest { const message = createBasePingRequest(); - message.input = object.input ?? ''; + message.input = object.input ?? ""; return message; }, }; function createBasePingResponse(): PingResponse { - return { output: '' }; + return { output: "" }; } export const PingResponse = { encode(message: PingResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.output !== '') { + if (message.output !== "") { writer.uint32(10).string(message.output); } return writer; @@ -1381,9 +1372,7 @@ export const PingResponse = { }, fromJSON(object: any): PingResponse { - return { - output: isSet(object.output) ? String(object.output) : '', - }; + return { output: isSet(object.output) ? String(object.output) : "" }; }, toJSON(message: PingResponse): unknown { @@ -1394,7 +1383,7 @@ export const PingResponse = { fromPartial, I>>(object: I): PingResponse { const message = createBasePingResponse(); - message.output = object.output ?? ''; + message.output = object.output ?? ""; return message; }, }; @@ -1591,9 +1580,7 @@ export const SimpleStruct = { }, fromJSON(object: any): SimpleStruct { - return { - simple_struct: isObject(object.simple_struct) ? object.simple_struct : undefined, - }; + return { simple_struct: isObject(object.simple_struct) ? object.simple_struct : undefined }; }, toJSON(message: SimpleStruct): unknown { @@ -1621,7 +1608,7 @@ export class PingServiceClientImpl implements PingService { } ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); - const promise = this.rpc.request('simple.PingService', 'ping', data); + const promise = this.rpc.request("simple.PingService", "ping", data); return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); } } @@ -1634,28 +1621,30 @@ 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'; + 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -1673,7 +1662,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); @@ -1682,7 +1671,7 @@ function fromJsonTimestamp(o: any): Date { function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } @@ -1695,7 +1684,7 @@ if (_m0.util.Long !== Long) { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/simple-string-enums/google/protobuf/struct.ts b/integration/simple-string-enums/google/protobuf/struct.ts index 98eae07df..4e88bc237 100644 --- a/integration/simple-string-enums/google/protobuf/struct.ts +++ b/integration/simple-string-enums/google/protobuf/struct.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the @@ -11,17 +11,17 @@ export const protobufPackage = 'google.protobuf'; */ export enum NullValue { /** NULL_VALUE - Null value. */ - NULL_VALUE = 'NULL_VALUE', - UNRECOGNIZED = 'UNRECOGNIZED', + NULL_VALUE = "NULL_VALUE", + UNRECOGNIZED = "UNRECOGNIZED", } export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: - case 'NULL_VALUE': + case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } @@ -30,10 +30,10 @@ export function nullValueFromJSON(object: any): NullValue { export function nullValueToJSON(object: NullValue): string { switch (object) { case NullValue.NULL_VALUE: - return 'NULL_VALUE'; + return "NULL_VALUE"; case NullValue.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -77,15 +77,25 @@ export interface Struct_FieldsEntry { */ export interface Value { /** Represents a null value. */ - nullValue: NullValue | undefined; + nullValue: + | NullValue + | undefined; /** Represents a double value. */ - numberValue: number | undefined; + numberValue: + | number + | undefined; /** Represents a string value. */ - stringValue: string | undefined; + stringValue: + | string + | undefined; /** Represents a boolean value. */ - boolValue: boolean | undefined; + boolValue: + | boolean + | undefined; /** Represents a structured value. */ - structValue: { [key: string]: any } | undefined; + structValue: + | { [key: string]: any } + | undefined; /** Represents a repeated `Value`. */ listValue: Array | undefined; } @@ -139,9 +149,9 @@ export const 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; - }, {}) + acc[key] = value as any | undefined; + return acc; + }, {}) : {}, }; }, @@ -166,7 +176,7 @@ export const Struct = { } return acc; }, - {} + {}, ); return message; }, @@ -191,12 +201,12 @@ export const Struct = { }; function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Struct_FieldsEntry = { encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -227,10 +237,7 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object?.value) ? object.value : undefined, - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -242,7 +249,7 @@ export const Struct_FieldsEntry = { fromPartial, I>>(object: I): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -354,18 +361,18 @@ export const Value = { if (value === null) { result.nullValue = NullValue.NULL_VALUE; - } else if (typeof value === 'boolean') { + } else if (typeof value === "boolean") { result.boolValue = value; - } else if (typeof value === 'number') { + } else if (typeof value === "number") { result.numberValue = value; - } else if (typeof value === 'string') { + } else if (typeof value === "string") { result.stringValue = value; } else if (Array.isArray(value)) { result.listValue = value; - } else if (typeof value === 'object') { + } else if (typeof value === "object") { result.structValue = value; - } else if (typeof value !== 'undefined') { - throw new Error('Unsupported any value type: ' + typeof value); + } else if (typeof value !== "undefined") { + throw new Error("Unsupported any value type: " + typeof value); } return result; @@ -420,9 +427,7 @@ export const ListValue = { }, fromJSON(object: any): ListValue { - return { - values: Array.isArray(object?.values) ? [...object.values] : [], - }; + return { values: Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { @@ -456,23 +461,17 @@ export const 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/simple-string-enums/simple.ts b/integration/simple-string-enums/simple.ts index 45c33d9ae..7d476abdf 100644 --- a/integration/simple-string-enums/simple.ts +++ b/integration/simple-string-enums/simple.ts @@ -1,29 +1,29 @@ /* eslint-disable */ -import { NullValue, nullValueToNumber, nullValueFromJSON, nullValueToJSON } from './google/protobuf/struct'; -import * as _m0 from 'protobufjs/minimal'; +import { NullValue, nullValueFromJSON, nullValueToJSON, nullValueToNumber } from "./google/protobuf/struct"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export enum StateEnum { - UNKNOWN = 'UNKNOWN', - ON = 'ON', - OFF = 'OFF', - UNRECOGNIZED = 'UNRECOGNIZED', + UNKNOWN = "UNKNOWN", + ON = "ON", + OFF = "OFF", + UNRECOGNIZED = "UNRECOGNIZED", } export function stateEnumFromJSON(object: any): StateEnum { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return StateEnum.UNKNOWN; case 2: - case 'ON': + case "ON": return StateEnum.ON; case 3: - case 'OFF': + case "OFF": return StateEnum.OFF; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return StateEnum.UNRECOGNIZED; } @@ -32,14 +32,14 @@ export function stateEnumFromJSON(object: any): StateEnum { export function stateEnumToJSON(object: StateEnum): string { switch (object) { case StateEnum.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case StateEnum.ON: - return 'ON'; + return "ON"; case StateEnum.OFF: - return 'OFF'; + return "OFF"; case StateEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -71,12 +71,12 @@ export interface Simple_StateMapEntry { } function createBaseSimple(): Simple { - return { name: '', state: StateEnum.UNKNOWN, states: [], nullValue: NullValue.NULL_VALUE, stateMap: {} }; + return { name: "", state: StateEnum.UNKNOWN, states: [], nullValue: NullValue.NULL_VALUE, stateMap: {} }; } export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.state !== StateEnum.UNKNOWN) { @@ -138,15 +138,15 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", state: isSet(object.state) ? stateEnumFromJSON(object.state) : StateEnum.UNKNOWN, states: Array.isArray(object?.states) ? object.states.map((e: any) => stateEnumFromJSON(e)) : [], nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : NullValue.NULL_VALUE, stateMap: isObject(object.stateMap) ? Object.entries(object.stateMap).reduce<{ [key: string]: StateEnum }>((acc, [key, value]) => { - acc[key] = stateEnumFromJSON(value); - return acc; - }, {}) + acc[key] = stateEnumFromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -172,7 +172,7 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.state = object.state ?? StateEnum.UNKNOWN; message.states = object.states?.map((e) => e) || []; message.nullValue = object.nullValue ?? NullValue.NULL_VALUE; @@ -183,19 +183,19 @@ export const Simple = { } return acc; }, - {} + {}, ); return message; }, }; function createBaseSimple_StateMapEntry(): Simple_StateMapEntry { - return { key: '', value: StateEnum.UNKNOWN }; + return { key: "", value: StateEnum.UNKNOWN }; } export const Simple_StateMapEntry = { encode(message: Simple_StateMapEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== StateEnum.UNKNOWN) { @@ -227,7 +227,7 @@ export const Simple_StateMapEntry = { fromJSON(object: any): Simple_StateMapEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? stateEnumFromJSON(object.value) : StateEnum.UNKNOWN, }; }, @@ -241,7 +241,7 @@ export const Simple_StateMapEntry = { fromPartial, I>>(object: I): Simple_StateMapEntry { const message = createBaseSimple_StateMapEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? StateEnum.UNKNOWN; return message; }, @@ -249,23 +249,17 @@ export const Simple_StateMapEntry = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts b/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts index c52fb2549..5497f7183 100644 --- a/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts +++ b/integration/simple-unrecognized-enum/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts b/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts index 5e90fd4da..3145298cb 100644 --- a/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts +++ b/integration/simple-unrecognized-enum/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial, I>>(object: I): StringValue { const message = createBaseStringValue(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), - }; + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,36 +552,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple-unrecognized-enum/import_dir/thing.ts b/integration/simple-unrecognized-enum/import_dir/thing.ts index 3313036e0..76bd88845 100644 --- a/integration/simple-unrecognized-enum/import_dir/thing.ts +++ b/integration/simple-unrecognized-enum/import_dir/thing.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { Timestamp } from '../google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; +import { Timestamp } from "../google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface ImportedThing { createdAt: Date | undefined; @@ -39,9 +39,7 @@ export const ImportedThing = { }, fromJSON(object: any): ImportedThing { - return { - createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, - }; + return { createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined }; }, toJSON(message: ImportedThing): unknown { @@ -59,19 +57,13 @@ export const ImportedThing = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -89,7 +81,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/simple-unrecognized-enum/simple.ts b/integration/simple-unrecognized-enum/simple.ts index 767ede048..92bf5e29e 100644 --- a/integration/simple-unrecognized-enum/simple.ts +++ b/integration/simple-unrecognized-enum/simple.ts @@ -1,11 +1,11 @@ /* eslint-disable */ -import { Timestamp } from './google/protobuf/timestamp'; -import * as Long from 'long'; -import { ImportedThing } from './import_dir/thing'; -import * as _m0 from 'protobufjs/minimal'; -import { StringValue, Int32Value, BoolValue } from './google/protobuf/wrappers'; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as Long from "long"; +import { ImportedThing } from "./import_dir/thing"; +import * as _m0 from "protobufjs/minimal"; +import { BoolValue, Int32Value, StringValue } from "./google/protobuf/wrappers"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; /** * Adding a comment to the syntax will become the first @@ -21,29 +21,29 @@ export enum StateEnum { export function stateEnumFromJSON(object: any): StateEnum { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return StateEnum.UNKNOWN; case 2: - case 'ON': + case "ON": return StateEnum.ON; case 3: - case 'OFF': + case "OFF": return StateEnum.OFF; default: - throw new globalThis.Error('Unrecognized enum value ' + object + ' for enum StateEnum'); + throw new globalThis.Error("Unrecognized enum value " + object + " for enum StateEnum"); } } export function stateEnumToJSON(object: StateEnum): string { switch (object) { case StateEnum.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case StateEnum.ON: - return 'ON'; + return "ON"; case StateEnum.OFF: - return 'OFF'; + return "OFF"; default: - throw new globalThis.Error('Unrecognized enum value ' + object + ' for enum StateEnum'); + throw new globalThis.Error("Unrecognized enum value " + object + " for enum StateEnum"); } } @@ -79,29 +79,29 @@ export enum Child_Type { export function child_TypeFromJSON(object: any): Child_Type { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return Child_Type.UNKNOWN; case 1: - case 'GOOD': + case "GOOD": return Child_Type.GOOD; case 2: - case 'BAD': + case "BAD": return Child_Type.BAD; default: - throw new globalThis.Error('Unrecognized enum value ' + object + ' for enum Child_Type'); + throw new globalThis.Error("Unrecognized enum value " + object + " for enum Child_Type"); } } export function child_TypeToJSON(object: Child_Type): string { switch (object) { case Child_Type.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case Child_Type.GOOD: - return 'GOOD'; + return "GOOD"; case Child_Type.BAD: - return 'BAD'; + return "BAD"; default: - throw new globalThis.Error('Unrecognized enum value ' + object + ' for enum Child_Type'); + throw new globalThis.Error("Unrecognized enum value " + object + " for enum Child_Type"); } } @@ -120,29 +120,29 @@ export enum Nested_InnerEnum { export function nested_InnerEnumFromJSON(object: any): Nested_InnerEnum { switch (object) { case 0: - case 'UNKNOWN_INNER': + case "UNKNOWN_INNER": return Nested_InnerEnum.UNKNOWN_INNER; case 100: - case 'GOOD': + case "GOOD": return Nested_InnerEnum.GOOD; case 1000: - case 'BAD': + case "BAD": return Nested_InnerEnum.BAD; default: - throw new globalThis.Error('Unrecognized enum value ' + object + ' for enum Nested_InnerEnum'); + throw new globalThis.Error("Unrecognized enum value " + object + " for enum Nested_InnerEnum"); } } export function nested_InnerEnumToJSON(object: Nested_InnerEnum): string { switch (object) { case Nested_InnerEnum.UNKNOWN_INNER: - return 'UNKNOWN_INNER'; + return "UNKNOWN_INNER"; case Nested_InnerEnum.GOOD: - return 'GOOD'; + return "GOOD"; case Nested_InnerEnum.BAD: - return 'BAD'; + return "BAD"; default: - throw new globalThis.Error('Unrecognized enum value ' + object + ' for enum Nested_InnerEnum'); + throw new globalThis.Error("Unrecognized enum value " + object + " for enum Nested_InnerEnum"); } } @@ -228,7 +228,7 @@ export interface Numbers { function createBaseSimple(): Simple { return { - name: '', + name: "", age: 0, createdAt: undefined, child: undefined, @@ -243,7 +243,7 @@ function createBaseSimple(): Simple { export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== 0) { @@ -341,7 +341,7 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, @@ -364,7 +364,7 @@ export const Simple = { message.child !== undefined && (obj.child = message.child ? Child.toJSON(message.child) : undefined); message.state !== undefined && (obj.state = stateEnumToJSON(message.state)); if (message.grandChildren) { - obj.grandChildren = message.grandChildren.map((e) => (e ? Child.toJSON(e) : undefined)); + obj.grandChildren = message.grandChildren.map((e) => e ? Child.toJSON(e) : undefined); } else { obj.grandChildren = []; } @@ -389,28 +389,29 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.age = object.age ?? 0; message.createdAt = object.createdAt ?? undefined; - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; message.state = object.state ?? 0; message.grandChildren = object.grandChildren?.map((e) => Child.fromPartial(e)) || []; message.coins = object.coins?.map((e) => e) || []; message.snacks = object.snacks?.map((e) => e) || []; message.oldStates = object.oldStates?.map((e) => e) || []; - message.thing = - object.thing !== undefined && object.thing !== null ? ImportedThing.fromPartial(object.thing) : undefined; + message.thing = (object.thing !== undefined && object.thing !== null) + ? ImportedThing.fromPartial(object.thing) + : undefined; return message; }, }; function createBaseChild(): Child { - return { name: '', type: 0 }; + return { name: "", type: 0 }; } export const Child = { encode(message: Child, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.type !== 0) { @@ -442,7 +443,7 @@ export const Child = { fromJSON(object: any): Child { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", type: isSet(object.type) ? child_TypeFromJSON(object.type) : 0, }; }, @@ -456,19 +457,19 @@ export const Child = { fromPartial, I>>(object: I): Child { const message = createBaseChild(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.type = object.type ?? 0; return message; }, }; function createBaseNested(): Nested { - return { name: '', message: undefined, state: 0 }; + return { name: "", message: undefined, state: 0 }; } export const Nested = { encode(message: Nested, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.message !== undefined) { @@ -506,7 +507,7 @@ export const Nested = { fromJSON(object: any): Nested { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", message: isSet(object.message) ? Nested_InnerMessage.fromJSON(object.message) : undefined, state: isSet(object.state) ? nested_InnerEnumFromJSON(object.state) : 0, }; @@ -523,23 +524,22 @@ export const Nested = { fromPartial, I>>(object: I): Nested { const message = createBaseNested(); - message.name = object.name ?? ''; - message.message = - object.message !== undefined && object.message !== null - ? Nested_InnerMessage.fromPartial(object.message) - : undefined; + message.name = object.name ?? ""; + message.message = (object.message !== undefined && object.message !== null) + ? Nested_InnerMessage.fromPartial(object.message) + : undefined; message.state = object.state ?? 0; return message; }, }; function createBaseNested_InnerMessage(): Nested_InnerMessage { - return { name: '', deep: undefined }; + return { name: "", deep: undefined }; } export const Nested_InnerMessage = { encode(message: Nested_InnerMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.deep !== undefined) { @@ -571,7 +571,7 @@ export const Nested_InnerMessage = { fromJSON(object: any): Nested_InnerMessage { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", deep: isSet(object.deep) ? Nested_InnerMessage_DeepMessage.fromJSON(object.deep) : undefined, }; }, @@ -586,22 +586,21 @@ export const Nested_InnerMessage = { fromPartial, I>>(object: I): Nested_InnerMessage { const message = createBaseNested_InnerMessage(); - message.name = object.name ?? ''; - message.deep = - object.deep !== undefined && object.deep !== null - ? Nested_InnerMessage_DeepMessage.fromPartial(object.deep) - : undefined; + message.name = object.name ?? ""; + message.deep = (object.deep !== undefined && object.deep !== null) + ? Nested_InnerMessage_DeepMessage.fromPartial(object.deep) + : undefined; return message; }, }; function createBaseNested_InnerMessage_DeepMessage(): Nested_InnerMessage_DeepMessage { - return { name: '' }; + return { name: "" }; } export const Nested_InnerMessage_DeepMessage = { encode(message: Nested_InnerMessage_DeepMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -626,9 +625,7 @@ export const Nested_InnerMessage_DeepMessage = { }, fromJSON(object: any): Nested_InnerMessage_DeepMessage { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Nested_InnerMessage_DeepMessage): unknown { @@ -638,10 +635,10 @@ export const Nested_InnerMessage_DeepMessage = { }, fromPartial, I>>( - object: I + object: I, ): Nested_InnerMessage_DeepMessage { const message = createBaseNested_InnerMessage_DeepMessage(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; @@ -828,9 +825,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { - id: isSet(object.id) ? Number(object.id) : 0, - }; + return { id: isSet(object.id) ? Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -901,21 +896,21 @@ export const SimpleWithMap = { return { entitiesById: isObject(object.entitiesById) ? Object.entries(object.entitiesById).reduce<{ [key: number]: Entity }>((acc, [key, value]) => { - acc[Number(key)] = Entity.fromJSON(value); - return acc; - }, {}) + acc[Number(key)] = Entity.fromJSON(value); + return acc; + }, {}) : {}, nameLookup: isObject(object.nameLookup) ? Object.entries(object.nameLookup).reduce<{ [key: string]: string }>((acc, [key, value]) => { - acc[key] = String(value); - return acc; - }, {}) + acc[key] = String(value); + return acc; + }, {}) : {}, intLookup: isObject(object.intLookup) ? Object.entries(object.intLookup).reduce<{ [key: number]: number }>((acc, [key, value]) => { - acc[Number(key)] = Number(value); - return acc; - }, {}) + acc[Number(key)] = Number(value); + return acc; + }, {}) : {}, }; }, @@ -952,7 +947,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { @@ -961,7 +956,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { @@ -970,7 +965,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); return message; }, @@ -1027,25 +1022,27 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_EntitiesByIdEntry { const message = createBaseSimpleWithMap_EntitiesByIdEntry(); message.key = object.key ?? 0; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; function createBaseSimpleWithMap_NameLookupEntry(): SimpleWithMap_NameLookupEntry { - return { key: '', value: '' }; + return { key: "", value: "" }; } export const SimpleWithMap_NameLookupEntry = { encode(message: SimpleWithMap_NameLookupEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -1073,10 +1070,7 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object.value) ? String(object.value) : '', - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -1087,11 +1081,11 @@ export const SimpleWithMap_NameLookupEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_NameLookupEntry { const message = createBaseSimpleWithMap_NameLookupEntry(); - message.key = object.key ?? ''; - message.value = object.value ?? ''; + message.key = object.key ?? ""; + message.value = object.value ?? ""; return message; }, }; @@ -1133,10 +1127,7 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { - key: isSet(object.key) ? Number(object.key) : 0, - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -1191,9 +1182,9 @@ export const SimpleWithSnakeCaseMap = { return { entitiesById: isObject(object.entitiesById) ? Object.entries(object.entitiesById).reduce<{ [key: number]: Entity }>((acc, [key, value]) => { - acc[Number(key)] = Entity.fromJSON(value); - return acc; - }, {}) + acc[Number(key)] = Entity.fromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -1218,7 +1209,7 @@ export const SimpleWithSnakeCaseMap = { } return acc; }, - {} + {}, ); return message; }, @@ -1275,22 +1266,24 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithSnakeCaseMap_EntitiesByIdEntry { const message = createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(); message.key = object.key ?? 0; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; function createBasePingRequest(): PingRequest { - return { input: '' }; + return { input: "" }; } export const PingRequest = { encode(message: PingRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.input !== '') { + if (message.input !== "") { writer.uint32(10).string(message.input); } return writer; @@ -1315,9 +1308,7 @@ export const PingRequest = { }, fromJSON(object: any): PingRequest { - return { - input: isSet(object.input) ? String(object.input) : '', - }; + return { input: isSet(object.input) ? String(object.input) : "" }; }, toJSON(message: PingRequest): unknown { @@ -1328,18 +1319,18 @@ export const PingRequest = { fromPartial, I>>(object: I): PingRequest { const message = createBasePingRequest(); - message.input = object.input ?? ''; + message.input = object.input ?? ""; return message; }, }; function createBasePingResponse(): PingResponse { - return { output: '' }; + return { output: "" }; } export const PingResponse = { encode(message: PingResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.output !== '') { + if (message.output !== "") { writer.uint32(10).string(message.output); } return writer; @@ -1364,9 +1355,7 @@ export const PingResponse = { }, fromJSON(object: any): PingResponse { - return { - output: isSet(object.output) ? String(object.output) : '', - }; + return { output: isSet(object.output) ? String(object.output) : "" }; }, toJSON(message: PingResponse): unknown { @@ -1377,7 +1366,7 @@ export const PingResponse = { fromPartial, I>>(object: I): PingResponse { const message = createBasePingResponse(); - message.output = object.output ?? ''; + message.output = object.output ?? ""; return message; }, }; @@ -1555,7 +1544,7 @@ export class PingServiceClientImpl implements PingService { } ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); - const promise = this.rpc.request('simple.PingService', 'ping', data); + const promise = this.rpc.request("simple.PingService", "ping", data); return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); } } @@ -1568,28 +1557,30 @@ 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'; + 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -1607,7 +1598,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); @@ -1616,7 +1607,7 @@ function fromJsonTimestamp(o: any): Date { function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } @@ -1629,7 +1620,7 @@ if (_m0.util.Long !== Long) { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/simple/google/protobuf/timestamp.ts b/integration/simple/google/protobuf/timestamp.ts index c52fb2549..5497f7183 100644 --- a/integration/simple/google/protobuf/timestamp.ts +++ b/integration/simple/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple/google/protobuf/wrappers.ts b/integration/simple/google/protobuf/wrappers.ts index 5e90fd4da..3145298cb 100644 --- a/integration/simple/google/protobuf/wrappers.ts +++ b/integration/simple/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial, I>>(object: I): StringValue { const message = createBaseStringValue(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), - }; + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,36 +552,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/simple/google/type/date.ts b/integration/simple/google/type/date.ts index bbb4db2b8..84b38cb0f 100644 --- a/integration/simple/google/type/date.ts +++ b/integration/simple/google/type/date.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.type'; +export const protobufPackage = "google.type"; /** * Represents a whole or partial calendar date, e.g. a birthday. The time of day @@ -103,19 +103,13 @@ export const DateMessage = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/simple/import_dir/thing.ts b/integration/simple/import_dir/thing.ts index 3313036e0..76bd88845 100644 --- a/integration/simple/import_dir/thing.ts +++ b/integration/simple/import_dir/thing.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { Timestamp } from '../google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; +import { Timestamp } from "../google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export interface ImportedThing { createdAt: Date | undefined; @@ -39,9 +39,7 @@ export const ImportedThing = { }, fromJSON(object: any): ImportedThing { - return { - createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, - }; + return { createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined }; }, toJSON(message: ImportedThing): unknown { @@ -59,19 +57,13 @@ export const ImportedThing = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -89,7 +81,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); diff --git a/integration/simple/simple.ts b/integration/simple/simple.ts index 6f2f00ee4..045a02578 100644 --- a/integration/simple/simple.ts +++ b/integration/simple/simple.ts @@ -1,12 +1,12 @@ /* eslint-disable */ -import { Timestamp } from './google/protobuf/timestamp'; -import * as Long from 'long'; -import { ImportedThing } from './import_dir/thing'; -import { DateMessage } from './google/type/date'; -import * as _m0 from 'protobufjs/minimal'; -import { StringValue, Int32Value, BoolValue, BytesValue } from './google/protobuf/wrappers'; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as Long from "long"; +import { ImportedThing } from "./import_dir/thing"; +import { DateMessage } from "./google/type/date"; +import * as _m0 from "protobufjs/minimal"; +import { BoolValue, BytesValue, Int32Value, StringValue } from "./google/protobuf/wrappers"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; /** * Adding a comment to the syntax will become the first @@ -23,16 +23,16 @@ export enum StateEnum { export function stateEnumFromJSON(object: any): StateEnum { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return StateEnum.UNKNOWN; case 2: - case 'ON': + case "ON": return StateEnum.ON; case 3: - case 'OFF': + case "OFF": return StateEnum.OFF; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return StateEnum.UNRECOGNIZED; } @@ -41,14 +41,14 @@ export function stateEnumFromJSON(object: any): StateEnum { export function stateEnumToJSON(object: StateEnum): string { switch (object) { case StateEnum.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case StateEnum.ON: - return 'ON'; + return "ON"; case StateEnum.OFF: - return 'OFF'; + return "OFF"; case StateEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -89,16 +89,16 @@ export enum Child_Type { export function child_TypeFromJSON(object: any): Child_Type { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return Child_Type.UNKNOWN; case 1: - case 'GOOD': + case "GOOD": return Child_Type.GOOD; case 2: - case 'BAD': + case "BAD": return Child_Type.BAD; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return Child_Type.UNRECOGNIZED; } @@ -107,14 +107,14 @@ export function child_TypeFromJSON(object: any): Child_Type { export function child_TypeToJSON(object: Child_Type): string { switch (object) { case Child_Type.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case Child_Type.GOOD: - return 'GOOD'; + return "GOOD"; case Child_Type.BAD: - return 'BAD'; + return "BAD"; case Child_Type.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -134,16 +134,16 @@ export enum Nested_InnerEnum { export function nested_InnerEnumFromJSON(object: any): Nested_InnerEnum { switch (object) { case 0: - case 'UNKNOWN_INNER': + case "UNKNOWN_INNER": return Nested_InnerEnum.UNKNOWN_INNER; case 100: - case 'GOOD': + case "GOOD": return Nested_InnerEnum.GOOD; case 1000: - case 'BAD': + case "BAD": return Nested_InnerEnum.BAD; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return Nested_InnerEnum.UNRECOGNIZED; } @@ -152,14 +152,14 @@ export function nested_InnerEnumFromJSON(object: any): Nested_InnerEnum { export function nested_InnerEnumToJSON(object: Nested_InnerEnum): string { switch (object) { case Nested_InnerEnum.UNKNOWN_INNER: - return 'UNKNOWN_INNER'; + return "UNKNOWN_INNER"; case Nested_InnerEnum.GOOD: - return 'GOOD'; + return "GOOD"; case Nested_InnerEnum.BAD: - return 'BAD'; + return "BAD"; case Nested_InnerEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -280,23 +280,30 @@ export interface Numbers { /** For testing proto3's field presence feature. */ export interface SimpleButOptional { /** Name field */ - name?: string | undefined; + name?: + | string + | undefined; /** Age */ - age?: number | undefined; + age?: + | number + | undefined; /** This comment will also attach */ createdAt?: Date | undefined; child?: Child | undefined; - state?: StateEnum | undefined; + state?: + | StateEnum + | undefined; /** A thing (imported from thing) */ thing?: ImportedThing | undefined; birthday?: DateMessage | undefined; } -export interface Empty {} +export interface Empty { +} function createBaseSimple(): Simple { return { - name: '', + name: "", age: 0, createdAt: undefined, child: undefined, @@ -315,7 +322,7 @@ function createBaseSimple(): Simple { export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.age !== 0) { @@ -437,7 +444,7 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", age: isSet(object.age) ? Number(object.age) : 0, createdAt: isSet(object.createdAt) ? fromJsonTimestamp(object.createdAt) : undefined, child: isSet(object.child) ? Child.fromJSON(object.child) : undefined, @@ -464,7 +471,7 @@ export const Simple = { message.child !== undefined && (obj.child = message.child ? Child.toJSON(message.child) : undefined); message.state !== undefined && (obj.state = stateEnumToJSON(message.state)); if (message.grandChildren) { - obj.grandChildren = message.grandChildren.map((e) => (e ? Child.toJSON(e) : undefined)); + obj.grandChildren = message.grandChildren.map((e) => e ? Child.toJSON(e) : undefined); } else { obj.grandChildren = []; } @@ -499,20 +506,22 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.age = object.age ?? 0; message.createdAt = object.createdAt ?? undefined; - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; message.state = object.state ?? 0; message.grandChildren = object.grandChildren?.map((e) => Child.fromPartial(e)) || []; message.coins = object.coins?.map((e) => e) || []; message.snacks = object.snacks?.map((e) => e) || []; message.oldStates = object.oldStates?.map((e) => e) || []; - message.thing = - object.thing !== undefined && object.thing !== null ? ImportedThing.fromPartial(object.thing) : undefined; + message.thing = (object.thing !== undefined && object.thing !== null) + ? ImportedThing.fromPartial(object.thing) + : undefined; message.blobs = object.blobs?.map((e) => e) || []; - message.birthday = - object.birthday !== undefined && object.birthday !== null ? DateMessage.fromPartial(object.birthday) : undefined; + message.birthday = (object.birthday !== undefined && object.birthday !== null) + ? DateMessage.fromPartial(object.birthday) + : undefined; message.blob = object.blob ?? new Uint8Array(); message.enabled = object.enabled ?? false; return message; @@ -520,12 +529,12 @@ export const Simple = { }; function createBaseChild(): Child { - return { name: '', type: 0 }; + return { name: "", type: 0 }; } export const Child = { encode(message: Child, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.type !== 0) { @@ -557,7 +566,7 @@ export const Child = { fromJSON(object: any): Child { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", type: isSet(object.type) ? child_TypeFromJSON(object.type) : 0, }; }, @@ -571,19 +580,19 @@ export const Child = { fromPartial, I>>(object: I): Child { const message = createBaseChild(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.type = object.type ?? 0; return message; }, }; function createBaseNested(): Nested { - return { name: '', message: undefined, state: 0 }; + return { name: "", message: undefined, state: 0 }; } export const Nested = { encode(message: Nested, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.message !== undefined) { @@ -621,7 +630,7 @@ export const Nested = { fromJSON(object: any): Nested { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", message: isSet(object.message) ? Nested_InnerMessage.fromJSON(object.message) : undefined, state: isSet(object.state) ? nested_InnerEnumFromJSON(object.state) : 0, }; @@ -638,23 +647,22 @@ export const Nested = { fromPartial, I>>(object: I): Nested { const message = createBaseNested(); - message.name = object.name ?? ''; - message.message = - object.message !== undefined && object.message !== null - ? Nested_InnerMessage.fromPartial(object.message) - : undefined; + message.name = object.name ?? ""; + message.message = (object.message !== undefined && object.message !== null) + ? Nested_InnerMessage.fromPartial(object.message) + : undefined; message.state = object.state ?? 0; return message; }, }; function createBaseNested_InnerMessage(): Nested_InnerMessage { - return { name: '', deep: undefined }; + return { name: "", deep: undefined }; } export const Nested_InnerMessage = { encode(message: Nested_InnerMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.deep !== undefined) { @@ -686,7 +694,7 @@ export const Nested_InnerMessage = { fromJSON(object: any): Nested_InnerMessage { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", deep: isSet(object.deep) ? Nested_InnerMessage_DeepMessage.fromJSON(object.deep) : undefined, }; }, @@ -701,22 +709,21 @@ export const Nested_InnerMessage = { fromPartial, I>>(object: I): Nested_InnerMessage { const message = createBaseNested_InnerMessage(); - message.name = object.name ?? ''; - message.deep = - object.deep !== undefined && object.deep !== null - ? Nested_InnerMessage_DeepMessage.fromPartial(object.deep) - : undefined; + message.name = object.name ?? ""; + message.deep = (object.deep !== undefined && object.deep !== null) + ? Nested_InnerMessage_DeepMessage.fromPartial(object.deep) + : undefined; return message; }, }; function createBaseNested_InnerMessage_DeepMessage(): Nested_InnerMessage_DeepMessage { - return { name: '' }; + return { name: "" }; } export const Nested_InnerMessage_DeepMessage = { encode(message: Nested_InnerMessage_DeepMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } return writer; @@ -741,9 +748,7 @@ export const Nested_InnerMessage_DeepMessage = { }, fromJSON(object: any): Nested_InnerMessage_DeepMessage { - return { - name: isSet(object.name) ? String(object.name) : '', - }; + return { name: isSet(object.name) ? String(object.name) : "" }; }, toJSON(message: Nested_InnerMessage_DeepMessage): unknown { @@ -753,10 +758,10 @@ export const Nested_InnerMessage_DeepMessage = { }, fromPartial, I>>( - object: I + object: I, ): Nested_InnerMessage_DeepMessage { const message = createBaseNested_InnerMessage_DeepMessage(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; return message; }, }; @@ -952,9 +957,7 @@ export const Entity = { }, fromJSON(object: any): Entity { - return { - id: isSet(object.id) ? Number(object.id) : 0, - }; + return { id: isSet(object.id) ? Number(object.id) : 0 }; }, toJSON(message: Entity): unknown { @@ -1071,48 +1074,48 @@ export const SimpleWithMap = { return { entitiesById: isObject(object.entitiesById) ? Object.entries(object.entitiesById).reduce<{ [key: number]: Entity }>((acc, [key, value]) => { - acc[Number(key)] = Entity.fromJSON(value); - return acc; - }, {}) + acc[Number(key)] = Entity.fromJSON(value); + return acc; + }, {}) : {}, nameLookup: isObject(object.nameLookup) ? Object.entries(object.nameLookup).reduce<{ [key: string]: string }>((acc, [key, value]) => { - acc[key] = String(value); - return acc; - }, {}) + acc[key] = String(value); + return acc; + }, {}) : {}, intLookup: isObject(object.intLookup) ? Object.entries(object.intLookup).reduce<{ [key: number]: number }>((acc, [key, value]) => { - acc[Number(key)] = Number(value); - return acc; - }, {}) + acc[Number(key)] = Number(value); + return acc; + }, {}) : {}, mapOfTimestamps: isObject(object.mapOfTimestamps) ? Object.entries(object.mapOfTimestamps).reduce<{ [key: string]: Date }>((acc, [key, value]) => { - acc[key] = fromJsonTimestamp(value); - return acc; - }, {}) + acc[key] = fromJsonTimestamp(value); + return acc; + }, {}) : {}, mapOfBytes: isObject(object.mapOfBytes) ? Object.entries(object.mapOfBytes).reduce<{ [key: string]: Uint8Array }>((acc, [key, value]) => { - acc[key] = bytesFromBase64(value as string); - return acc; - }, {}) + acc[key] = bytesFromBase64(value as string); + return acc; + }, {}) : {}, mapOfStringValues: isObject(object.mapOfStringValues) ? Object.entries(object.mapOfStringValues).reduce<{ [key: string]: string | undefined }>( - (acc, [key, value]) => { - acc[key] = value as string | undefined; - return acc; - }, - {} - ) + (acc, [key, value]) => { + acc[key] = value as string | undefined; + return acc; + }, + {}, + ) : {}, longLookup: isObject(object.longLookup) ? Object.entries(object.longLookup).reduce<{ [key: number]: number }>((acc, [key, value]) => { - acc[Number(key)] = Number(value); - return acc; - }, {}) + acc[Number(key)] = Number(value); + return acc; + }, {}) : {}, }; }, @@ -1173,7 +1176,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.nameLookup = Object.entries(object.nameLookup ?? {}).reduce<{ [key: string]: string }>( (acc, [key, value]) => { @@ -1182,7 +1185,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.intLookup = Object.entries(object.intLookup ?? {}).reduce<{ [key: number]: number }>( (acc, [key, value]) => { @@ -1191,7 +1194,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.mapOfTimestamps = Object.entries(object.mapOfTimestamps ?? {}).reduce<{ [key: string]: Date }>( (acc, [key, value]) => { @@ -1200,7 +1203,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); message.mapOfBytes = Object.entries(object.mapOfBytes ?? {}).reduce<{ [key: string]: Uint8Array }>( (acc, [key, value]) => { @@ -1209,11 +1212,11 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); - message.mapOfStringValues = Object.entries(object.mapOfStringValues ?? {}).reduce<{ - [key: string]: string | undefined; - }>((acc, [key, value]) => { + message.mapOfStringValues = Object.entries(object.mapOfStringValues ?? {}).reduce< + { [key: string]: string | undefined } + >((acc, [key, value]) => { if (value !== undefined) { acc[key] = value; } @@ -1226,7 +1229,7 @@ export const SimpleWithMap = { } return acc; }, - {} + {}, ); return message; }, @@ -1283,25 +1286,27 @@ export const SimpleWithMap_EntitiesByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_EntitiesByIdEntry { const message = createBaseSimpleWithMap_EntitiesByIdEntry(); message.key = object.key ?? 0; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; function createBaseSimpleWithMap_NameLookupEntry(): SimpleWithMap_NameLookupEntry { - return { key: '', value: '' }; + return { key: "", value: "" }; } export const SimpleWithMap_NameLookupEntry = { encode(message: SimpleWithMap_NameLookupEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -1329,10 +1334,7 @@ export const SimpleWithMap_NameLookupEntry = { }, fromJSON(object: any): SimpleWithMap_NameLookupEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object.value) ? String(object.value) : '', - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: SimpleWithMap_NameLookupEntry): unknown { @@ -1343,11 +1345,11 @@ export const SimpleWithMap_NameLookupEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_NameLookupEntry { const message = createBaseSimpleWithMap_NameLookupEntry(); - message.key = object.key ?? ''; - message.value = object.value ?? ''; + message.key = object.key ?? ""; + message.value = object.value ?? ""; return message; }, }; @@ -1389,10 +1391,7 @@ export const SimpleWithMap_IntLookupEntry = { }, fromJSON(object: any): SimpleWithMap_IntLookupEntry { - return { - key: isSet(object.key) ? Number(object.key) : 0, - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: SimpleWithMap_IntLookupEntry): unknown { @@ -1411,12 +1410,12 @@ export const SimpleWithMap_IntLookupEntry = { }; function createBaseSimpleWithMap_MapOfTimestampsEntry(): SimpleWithMap_MapOfTimestampsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const SimpleWithMap_MapOfTimestampsEntry = { encode(message: SimpleWithMap_MapOfTimestampsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -1448,7 +1447,7 @@ export const SimpleWithMap_MapOfTimestampsEntry = { fromJSON(object: any): SimpleWithMap_MapOfTimestampsEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? fromJsonTimestamp(object.value) : undefined, }; }, @@ -1461,22 +1460,22 @@ export const SimpleWithMap_MapOfTimestampsEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_MapOfTimestampsEntry { const message = createBaseSimpleWithMap_MapOfTimestampsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, }; function createBaseSimpleWithMap_MapOfBytesEntry(): SimpleWithMap_MapOfBytesEntry { - return { key: '', value: new Uint8Array() }; + return { key: "", value: new Uint8Array() }; } export const SimpleWithMap_MapOfBytesEntry = { encode(message: SimpleWithMap_MapOfBytesEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value.length !== 0) { @@ -1508,7 +1507,7 @@ export const SimpleWithMap_MapOfBytesEntry = { fromJSON(object: any): SimpleWithMap_MapOfBytesEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), }; }, @@ -1522,22 +1521,22 @@ export const SimpleWithMap_MapOfBytesEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_MapOfBytesEntry { const message = createBaseSimpleWithMap_MapOfBytesEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? new Uint8Array(); return message; }, }; function createBaseSimpleWithMap_MapOfStringValuesEntry(): SimpleWithMap_MapOfStringValuesEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const SimpleWithMap_MapOfStringValuesEntry = { encode(message: SimpleWithMap_MapOfStringValuesEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -1569,7 +1568,7 @@ export const SimpleWithMap_MapOfStringValuesEntry = { fromJSON(object: any): SimpleWithMap_MapOfStringValuesEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : undefined, }; }, @@ -1582,10 +1581,10 @@ export const SimpleWithMap_MapOfStringValuesEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_MapOfStringValuesEntry { const message = createBaseSimpleWithMap_MapOfStringValuesEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -1628,10 +1627,7 @@ export const SimpleWithMap_LongLookupEntry = { }, fromJSON(object: any): SimpleWithMap_LongLookupEntry { - return { - key: isSet(object.key) ? Number(object.key) : 0, - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { key: isSet(object.key) ? Number(object.key) : 0, value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: SimpleWithMap_LongLookupEntry): unknown { @@ -1642,7 +1638,7 @@ export const SimpleWithMap_LongLookupEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMap_LongLookupEntry { const message = createBaseSimpleWithMap_LongLookupEntry(); message.key = object.key ?? 0; @@ -1688,9 +1684,9 @@ export const SimpleWithSnakeCaseMap = { return { entitiesById: isObject(object.entitiesById) ? Object.entries(object.entitiesById).reduce<{ [key: number]: Entity }>((acc, [key, value]) => { - acc[Number(key)] = Entity.fromJSON(value); - return acc; - }, {}) + acc[Number(key)] = Entity.fromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -1715,7 +1711,7 @@ export const SimpleWithSnakeCaseMap = { } return acc; }, - {} + {}, ); return message; }, @@ -1772,11 +1768,13 @@ export const SimpleWithSnakeCaseMap_EntitiesByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithSnakeCaseMap_EntitiesByIdEntry { const message = createBaseSimpleWithSnakeCaseMap_EntitiesByIdEntry(); message.key = object.key ?? 0; - message.value = object.value !== undefined && object.value !== null ? Entity.fromPartial(object.value) : undefined; + message.value = (object.value !== undefined && object.value !== null) + ? Entity.fromPartial(object.value) + : undefined; return message; }, }; @@ -1818,9 +1816,9 @@ export const SimpleWithMapOfEnums = { return { enumsById: isObject(object.enumsById) ? Object.entries(object.enumsById).reduce<{ [key: number]: StateEnum }>((acc, [key, value]) => { - acc[Number(key)] = stateEnumFromJSON(value); - return acc; - }, {}) + acc[Number(key)] = stateEnumFromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -1845,7 +1843,7 @@ export const SimpleWithMapOfEnums = { } return acc; }, - {} + {}, ); return message; }, @@ -1902,7 +1900,7 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { }, fromPartial, I>>( - object: I + object: I, ): SimpleWithMapOfEnums_EnumsByIdEntry { const message = createBaseSimpleWithMapOfEnums_EnumsByIdEntry(); message.key = object.key ?? 0; @@ -1912,12 +1910,12 @@ export const SimpleWithMapOfEnums_EnumsByIdEntry = { }; function createBasePingRequest(): PingRequest { - return { input: '' }; + return { input: "" }; } export const PingRequest = { encode(message: PingRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.input !== '') { + if (message.input !== "") { writer.uint32(10).string(message.input); } return writer; @@ -1942,9 +1940,7 @@ export const PingRequest = { }, fromJSON(object: any): PingRequest { - return { - input: isSet(object.input) ? String(object.input) : '', - }; + return { input: isSet(object.input) ? String(object.input) : "" }; }, toJSON(message: PingRequest): unknown { @@ -1955,18 +1951,18 @@ export const PingRequest = { fromPartial, I>>(object: I): PingRequest { const message = createBasePingRequest(); - message.input = object.input ?? ''; + message.input = object.input ?? ""; return message; }, }; function createBasePingResponse(): PingResponse { - return { output: '' }; + return { output: "" }; } export const PingResponse = { encode(message: PingResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.output !== '') { + if (message.output !== "") { writer.uint32(10).string(message.output); } return writer; @@ -1991,9 +1987,7 @@ export const PingResponse = { }, fromJSON(object: any): PingResponse { - return { - output: isSet(object.output) ? String(object.output) : '', - }; + return { output: isSet(object.output) ? String(object.output) : "" }; }, toJSON(message: PingResponse): unknown { @@ -2004,7 +1998,7 @@ export const PingResponse = { fromPartial, I>>(object: I): PingResponse { const message = createBasePingResponse(); - message.output = object.output ?? ''; + message.output = object.output ?? ""; return message; }, }; @@ -2275,12 +2269,14 @@ export const SimpleButOptional = { message.name = object.name ?? undefined; message.age = object.age ?? undefined; message.createdAt = object.createdAt ?? undefined; - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; message.state = object.state ?? undefined; - message.thing = - object.thing !== undefined && object.thing !== null ? ImportedThing.fromPartial(object.thing) : undefined; - message.birthday = - object.birthday !== undefined && object.birthday !== null ? DateMessage.fromPartial(object.birthday) : undefined; + message.thing = (object.thing !== undefined && object.thing !== null) + ? ImportedThing.fromPartial(object.thing) + : undefined; + message.birthday = (object.birthday !== undefined && object.birthday !== null) + ? DateMessage.fromPartial(object.birthday) + : undefined; return message; }, }; @@ -2336,7 +2332,7 @@ export class PingServiceClientImpl implements PingService { } ping(request: PingRequest): Promise { const data = PingRequest.encode(request).finish(); - const promise = this.rpc.request('simple.PingService', 'ping', data); + const promise = this.rpc.request("simple.PingService", "ping", data); return promise.then((data) => PingResponse.decode(new _m0.Reader(data))); } } @@ -2349,16 +2345,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -2371,31 +2375,25 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -2413,7 +2411,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); @@ -2422,7 +2420,7 @@ function fromJsonTimestamp(o: any): Date { function longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } @@ -2435,7 +2433,7 @@ if (_m0.util.Long !== Long) { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/struct/google/protobuf/struct.ts b/integration/struct/google/protobuf/struct.ts index b764acb36..80a98258e 100644 --- a/integration/struct/google/protobuf/struct.ts +++ b/integration/struct/google/protobuf/struct.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the @@ -18,10 +18,10 @@ export enum NullValue { export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: - case 'NULL_VALUE': + case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } @@ -30,10 +30,10 @@ export function nullValueFromJSON(object: any): NullValue { export function nullValueToJSON(object: NullValue): string { switch (object) { case NullValue.NULL_VALUE: - return 'NULL_VALUE'; + return "NULL_VALUE"; case NullValue.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -67,15 +67,25 @@ export interface Struct_FieldsEntry { */ export interface Value { /** Represents a null value. */ - nullValue: NullValue | undefined; + nullValue: + | NullValue + | undefined; /** Represents a double value. */ - numberValue: number | undefined; + numberValue: + | number + | undefined; /** Represents a string value. */ - stringValue: string | undefined; + stringValue: + | string + | undefined; /** Represents a boolean value. */ - boolValue: boolean | undefined; + boolValue: + | boolean + | undefined; /** Represents a structured value. */ - structValue: { [key: string]: any } | undefined; + structValue: + | { [key: string]: any } + | undefined; /** Represents a repeated `Value`. */ listValue: Array | undefined; } @@ -129,9 +139,9 @@ export const 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; - }, {}) + acc[key] = value as any | undefined; + return acc; + }, {}) : {}, }; }, @@ -156,7 +166,7 @@ export const Struct = { } return acc; }, - {} + {}, ); return message; }, @@ -181,12 +191,12 @@ export const Struct = { }; function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Struct_FieldsEntry = { encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -217,10 +227,7 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object?.value) ? object.value : undefined, - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -232,7 +239,7 @@ export const Struct_FieldsEntry = { fromPartial, I>>(object: I): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -344,18 +351,18 @@ export const Value = { if (value === null) { result.nullValue = NullValue.NULL_VALUE; - } else if (typeof value === 'boolean') { + } else if (typeof value === "boolean") { result.boolValue = value; - } else if (typeof value === 'number') { + } else if (typeof value === "number") { result.numberValue = value; - } else if (typeof value === 'string') { + } else if (typeof value === "string") { result.stringValue = value; } else if (Array.isArray(value)) { result.listValue = value; - } else if (typeof value === 'object') { + } else if (typeof value === "object") { result.structValue = value; - } else if (typeof value !== 'undefined') { - throw new Error('Unsupported any value type: ' + typeof value); + } else if (typeof value !== "undefined") { + throw new Error("Unsupported any value type: " + typeof value); } return result; @@ -410,9 +417,7 @@ export const ListValue = { }, fromJSON(object: any): ListValue { - return { - values: Array.isArray(object?.values) ? [...object.values] : [], - }; + return { values: Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { @@ -446,23 +451,17 @@ export const 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/struct/struct.ts b/integration/struct/struct.ts index d39105dd1..ba99447e2 100644 --- a/integration/struct/struct.ts +++ b/integration/struct/struct.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; -import { Struct } from './google/protobuf/struct'; +import * as _m0 from "protobufjs/minimal"; +import { Struct } from "./google/protobuf/struct"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface StructMessage { value: { [key: string]: any } | undefined; @@ -39,9 +39,7 @@ export const StructMessage = { }, fromJSON(object: any): StructMessage { - return { - value: isObject(object.value) ? object.value : undefined, - }; + return { value: isObject(object.value) ? object.value : undefined }; }, toJSON(message: StructMessage): unknown { @@ -59,21 +57,15 @@ export const StructMessage = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } diff --git a/integration/type-registry/bar/bar.ts b/integration/type-registry/bar/bar.ts index f328ee33c..7e760dcdf 100644 --- a/integration/type-registry/bar/bar.ts +++ b/integration/type-registry/bar/bar.ts @@ -1,21 +1,21 @@ /* eslint-disable */ -import { messageTypeRegistry } from '../typeRegistry'; -import { Foo } from '../foo'; -import * as _m0 from 'protobufjs/minimal'; +import { messageTypeRegistry } from "../typeRegistry"; +import { Foo } from "../foo"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'foo.bar'; +export const protobufPackage = "foo.bar"; export interface Bar { - $type: 'foo.bar.Bar'; + $type: "foo.bar.Bar"; foo: Foo | undefined; } function createBaseBar(): Bar { - return { $type: 'foo.bar.Bar', foo: undefined }; + return { $type: "foo.bar.Bar", foo: undefined }; } export const Bar = { - $type: 'foo.bar.Bar' as const, + $type: "foo.bar.Bar" as const, encode(message: Bar, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.foo !== undefined) { @@ -43,10 +43,7 @@ export const Bar = { }, fromJSON(object: any): Bar { - return { - $type: Bar.$type, - foo: isSet(object.foo) ? Foo.fromJSON(object.foo) : undefined, - }; + return { $type: Bar.$type, foo: isSet(object.foo) ? Foo.fromJSON(object.foo) : undefined }; }, toJSON(message: Bar): unknown { @@ -57,7 +54,7 @@ export const Bar = { fromPartial, I>>(object: I): Bar { const message = createBaseBar(); - message.foo = object.foo !== undefined && object.foo !== null ? Foo.fromPartial(object.foo) : undefined; + message.foo = (object.foo !== undefined && object.foo !== null) ? Foo.fromPartial(object.foo) : undefined; return message; }, }; @@ -66,20 +63,14 @@ messageTypeRegistry.set(Bar.$type, 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 Exclude]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in Exclude]?: 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 }; +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/foo.ts b/integration/type-registry/foo.ts index 814878ab7..bbc0b2b01 100644 --- a/integration/type-registry/foo.ts +++ b/integration/type-registry/foo.ts @@ -1,32 +1,32 @@ /* eslint-disable */ -import { messageTypeRegistry } from './typeRegistry'; -import { Timestamp } from './google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; -import { Struct } from './google/protobuf/struct'; +import { messageTypeRegistry } from "./typeRegistry"; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; +import { Struct } from "./google/protobuf/struct"; -export const protobufPackage = 'foo'; +export const protobufPackage = "foo"; export interface Foo { - $type: 'foo.Foo'; + $type: "foo.Foo"; timestamp: Date | undefined; } export interface Foo2 { - $type: 'foo.Foo2'; + $type: "foo.Foo2"; timestamp: Date | undefined; } export interface WithStruct { - $type: 'foo.WithStruct'; + $type: "foo.WithStruct"; struct: { [key: string]: any } | undefined; } function createBaseFoo(): Foo { - return { $type: 'foo.Foo', timestamp: undefined }; + return { $type: "foo.Foo", timestamp: undefined }; } export const Foo = { - $type: 'foo.Foo' as const, + $type: "foo.Foo" as const, encode(message: Foo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.timestamp !== undefined) { @@ -54,10 +54,7 @@ export const Foo = { }, fromJSON(object: any): Foo { - return { - $type: Foo.$type, - timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, - }; + return { $type: Foo.$type, timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined }; }, toJSON(message: Foo): unknown { @@ -76,11 +73,11 @@ export const Foo = { messageTypeRegistry.set(Foo.$type, Foo); function createBaseFoo2(): Foo2 { - return { $type: 'foo.Foo2', timestamp: undefined }; + return { $type: "foo.Foo2", timestamp: undefined }; } export const Foo2 = { - $type: 'foo.Foo2' as const, + $type: "foo.Foo2" as const, encode(message: Foo2, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.timestamp !== undefined) { @@ -108,10 +105,7 @@ export const Foo2 = { }, fromJSON(object: any): Foo2 { - return { - $type: Foo2.$type, - timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, - }; + return { $type: Foo2.$type, timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined }; }, toJSON(message: Foo2): unknown { @@ -130,11 +124,11 @@ export const Foo2 = { messageTypeRegistry.set(Foo2.$type, Foo2); function createBaseWithStruct(): WithStruct { - return { $type: 'foo.WithStruct', struct: undefined }; + return { $type: "foo.WithStruct", struct: undefined }; } export const WithStruct = { - $type: 'foo.WithStruct' as const, + $type: "foo.WithStruct" as const, encode(message: WithStruct, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.struct !== undefined) { @@ -162,10 +156,7 @@ export const WithStruct = { }, fromJSON(object: any): WithStruct { - return { - $type: WithStruct.$type, - struct: isObject(object.struct) ? object.struct : undefined, - }; + return { $type: WithStruct.$type, struct: isObject(object.struct) ? object.struct : undefined }; }, toJSON(message: WithStruct): unknown { @@ -185,25 +176,19 @@ messageTypeRegistry.set(WithStruct.$type, 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 Exclude]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in Exclude]?: 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 }; +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 { $type: 'google.protobuf.Timestamp', seconds, nanos }; + return { $type: "google.protobuf.Timestamp", seconds, nanos }; } function fromTimestamp(t: Timestamp): Date { @@ -215,7 +200,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); @@ -223,7 +208,7 @@ function fromJsonTimestamp(o: any): Date { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/type-registry/google/protobuf/struct.ts b/integration/type-registry/google/protobuf/struct.ts index 4560fa35c..74acf4406 100644 --- a/integration/type-registry/google/protobuf/struct.ts +++ b/integration/type-registry/google/protobuf/struct.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { messageTypeRegistry } from '../../typeRegistry'; -import * as _m0 from 'protobufjs/minimal'; +import { messageTypeRegistry } from "../../typeRegistry"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the @@ -19,10 +19,10 @@ export enum NullValue { export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: - case 'NULL_VALUE': + case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } @@ -31,10 +31,10 @@ export function nullValueFromJSON(object: any): NullValue { export function nullValueToJSON(object: NullValue): string { switch (object) { case NullValue.NULL_VALUE: - return 'NULL_VALUE'; + return "NULL_VALUE"; case NullValue.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -49,13 +49,13 @@ export function nullValueToJSON(object: NullValue): string { * The JSON representation for `Struct` is JSON object. */ export interface Struct { - $type: 'google.protobuf.Struct'; + $type: "google.protobuf.Struct"; /** Unordered map of dynamically typed values. */ fields: { [key: string]: any | undefined }; } export interface Struct_FieldsEntry { - $type: 'google.protobuf.Struct.FieldsEntry'; + $type: "google.protobuf.Struct.FieldsEntry"; key: string; value: any | undefined; } @@ -69,17 +69,27 @@ export interface Struct_FieldsEntry { * The JSON representation for `Value` is JSON value. */ export interface Value { - $type: 'google.protobuf.Value'; + $type: "google.protobuf.Value"; /** Represents a null value. */ - nullValue: NullValue | undefined; + nullValue: + | NullValue + | undefined; /** Represents a double value. */ - numberValue: number | undefined; + numberValue: + | number + | undefined; /** Represents a string value. */ - stringValue: string | undefined; + stringValue: + | string + | undefined; /** Represents a boolean value. */ - boolValue: boolean | undefined; + boolValue: + | boolean + | undefined; /** Represents a structured value. */ - structValue: { [key: string]: any } | undefined; + structValue: + | { [key: string]: any } + | undefined; /** Represents a repeated `Value`. */ listValue: Array | undefined; } @@ -90,24 +100,24 @@ export interface Value { * The JSON representation for `ListValue` is JSON array. */ export interface ListValue { - $type: 'google.protobuf.ListValue'; + $type: "google.protobuf.ListValue"; /** Repeated field of dynamically typed values. */ values: any[]; } function createBaseStruct(): Struct { - return { $type: 'google.protobuf.Struct', fields: {} }; + return { $type: "google.protobuf.Struct", fields: {} }; } export const Struct = { - $type: 'google.protobuf.Struct' as const, + $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) { Struct_FieldsEntry.encode( - { $type: 'google.protobuf.Struct.FieldsEntry', key: key as any, value }, - writer.uint32(10).fork() + { $type: "google.protobuf.Struct.FieldsEntry", key: key as any, value }, + writer.uint32(10).fork(), ).ldelim(); } }); @@ -140,9 +150,9 @@ export const Struct = { $type: Struct.$type, fields: isObject(object.fields) ? Object.entries(object.fields).reduce<{ [key: string]: any | undefined }>((acc, [key, value]) => { - acc[key] = value as any | undefined; - return acc; - }, {}) + acc[key] = value as any | undefined; + return acc; + }, {}) : {}, }; }, @@ -167,7 +177,7 @@ export const Struct = { } return acc; }, - {} + {}, ); return message; }, @@ -194,14 +204,14 @@ export const Struct = { messageTypeRegistry.set(Struct.$type, Struct); function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { - return { $type: 'google.protobuf.Struct.FieldsEntry', key: '', value: undefined }; + return { $type: "google.protobuf.Struct.FieldsEntry", key: "", value: undefined }; } export const Struct_FieldsEntry = { - $type: 'google.protobuf.Struct.FieldsEntry' as const, + $type: "google.protobuf.Struct.FieldsEntry" as const, encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -234,7 +244,7 @@ export const Struct_FieldsEntry = { fromJSON(object: any): Struct_FieldsEntry { return { $type: Struct_FieldsEntry.$type, - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined, }; }, @@ -248,7 +258,7 @@ export const Struct_FieldsEntry = { fromPartial, I>>(object: I): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -258,7 +268,7 @@ messageTypeRegistry.set(Struct_FieldsEntry.$type, Struct_FieldsEntry); function createBaseValue(): Value { return { - $type: 'google.protobuf.Value', + $type: "google.protobuf.Value", nullValue: undefined, numberValue: undefined, stringValue: undefined, @@ -269,7 +279,7 @@ function createBaseValue(): Value { } export const Value = { - $type: 'google.protobuf.Value' as const, + $type: "google.protobuf.Value" as const, encode(message: Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.nullValue !== undefined) { @@ -366,18 +376,18 @@ export const Value = { if (value === null) { result.nullValue = NullValue.NULL_VALUE; - } else if (typeof value === 'boolean') { + } else if (typeof value === "boolean") { result.boolValue = value; - } else if (typeof value === 'number') { + } else if (typeof value === "number") { result.numberValue = value; - } else if (typeof value === 'string') { + } else if (typeof value === "string") { result.stringValue = value; } else if (Array.isArray(value)) { result.listValue = value; - } else if (typeof value === 'object') { + } else if (typeof value === "object") { result.structValue = value; - } else if (typeof value !== 'undefined') { - throw new Error('Unsupported any value type: ' + typeof value); + } else if (typeof value !== "undefined") { + throw new Error("Unsupported any value type: " + typeof value); } return result; @@ -404,11 +414,11 @@ export const Value = { messageTypeRegistry.set(Value.$type, Value); function createBaseListValue(): ListValue { - return { $type: 'google.protobuf.ListValue', values: [] }; + return { $type: "google.protobuf.ListValue", values: [] }; } export const ListValue = { - $type: 'google.protobuf.ListValue' as const, + $type: "google.protobuf.ListValue" as const, encode(message: ListValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { for (const v of message.values) { @@ -436,10 +446,7 @@ export const ListValue = { }, fromJSON(object: any): ListValue { - return { - $type: ListValue.$type, - values: Array.isArray(object?.values) ? [...object.values] : [], - }; + return { $type: ListValue.$type, values: Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { @@ -475,23 +482,17 @@ messageTypeRegistry.set(ListValue.$type, 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 Exclude]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in Exclude]?: 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 }; +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; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/type-registry/google/protobuf/timestamp.ts b/integration/type-registry/google/protobuf/timestamp.ts index 177351739..9fc79b168 100644 --- a/integration/type-registry/google/protobuf/timestamp.ts +++ b/integration/type-registry/google/protobuf/timestamp.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { messageTypeRegistry } from '../../typeRegistry'; -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import { messageTypeRegistry } from "../../typeRegistry"; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -56,7 +56,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -65,7 +64,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -99,7 +97,7 @@ export const protobufPackage = 'google.protobuf'; * ) to obtain a formatter capable of generating timestamps in this format. */ export interface Timestamp { - $type: 'google.protobuf.Timestamp'; + $type: "google.protobuf.Timestamp"; /** * Represents seconds of UTC time since Unix epoch * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to @@ -116,11 +114,11 @@ export interface Timestamp { } function createBaseTimestamp(): Timestamp { - return { $type: 'google.protobuf.Timestamp', seconds: 0, nanos: 0 }; + return { $type: "google.protobuf.Timestamp", seconds: 0, nanos: 0 }; } export const Timestamp = { - $type: 'google.protobuf.Timestamp' as const, + $type: "google.protobuf.Timestamp" as const, encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { if (message.seconds !== 0) { @@ -182,33 +180,35 @@ 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'; + 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 Exclude]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in Exclude]?: 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 }; +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/type-registry/typeRegistry.ts b/integration/type-registry/typeRegistry.ts index 511267a2c..795709565 100644 --- a/integration/type-registry/typeRegistry.ts +++ b/integration/type-registry/typeRegistry.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; export interface MessageType { - $type: Message['$type']; + $type: Message["$type"]; encode(message: Message, writer?: _m0.Writer): _m0.Writer; decode(input: _m0.Reader | Uint8Array, length?: number): Message; fromJSON(object: any): Message; @@ -15,12 +15,7 @@ export type UnknownMessage = { $type: string }; 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 Exclude]?: DeepPartial } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in Exclude]?: DeepPartial } : Partial; diff --git a/integration/types-with-underscores/file.ts b/integration/types-with-underscores/file.ts index 9013221e9..f8764f977 100644 --- a/integration/types-with-underscores/file.ts +++ b/integration/types-with-underscores/file.ts @@ -1,13 +1,14 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface Baz { foo: FooBar | undefined; } -export interface FooBar {} +export interface FooBar { +} function createBaseBaz(): Baz { return { foo: undefined }; @@ -40,9 +41,7 @@ export const Baz = { }, fromJSON(object: any): Baz { - return { - foo: isSet(object.foo) ? FooBar.fromJSON(object.foo) : undefined, - }; + return { foo: isSet(object.foo) ? FooBar.fromJSON(object.foo) : undefined }; }, toJSON(message: Baz): unknown { @@ -53,7 +52,7 @@ export const Baz = { fromPartial, I>>(object: I): Baz { const message = createBaseBaz(); - message.foo = object.foo !== undefined && object.foo !== null ? FooBar.fromPartial(object.foo) : undefined; + message.foo = (object.foo !== undefined && object.foo !== null) ? FooBar.fromPartial(object.foo) : undefined; return message; }, }; @@ -99,19 +98,13 @@ export const FooBar = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/unknown-fields/google/protobuf/compiler/plugin.ts b/integration/unknown-fields/google/protobuf/compiler/plugin.ts index ab272f7f4..0ed17b03b 100644 --- a/integration/unknown-fields/google/protobuf/compiler/plugin.ts +++ b/integration/unknown-fields/google/protobuf/compiler/plugin.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import * as Long from 'long'; -import { FileDescriptorProto, GeneratedCodeInfo } from '../descriptor'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import { FileDescriptorProto, GeneratedCodeInfo } from "../descriptor"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf.compiler'; +export const protobufPackage = "google.protobuf.compiler"; /** The version number of protocol compiler. */ export interface Version { @@ -143,7 +143,7 @@ export interface CodeGeneratorResponse_File { } function createBaseVersion(): Version { - return { major: 0, minor: 0, patch: 0, suffix: '' }; + return { major: 0, minor: 0, patch: 0, suffix: "" }; } export const Version = { @@ -157,19 +157,19 @@ export const Version = { if (message.patch !== 0) { writer.uint32(24).int32(message.patch); } - if (message.suffix !== '') { + if (message.suffix !== "") { writer.uint32(34).string(message.suffix); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -212,7 +212,7 @@ export const Version = { }; function createBaseCodeGeneratorRequest(): CodeGeneratorRequest { - return { fileToGenerate: [], parameter: '', protoFile: [], compilerVersion: undefined }; + return { fileToGenerate: [], parameter: "", protoFile: [], compilerVersion: undefined }; } export const CodeGeneratorRequest = { @@ -220,7 +220,7 @@ export const CodeGeneratorRequest = { for (const v of message.fileToGenerate) { writer.uint32(10).string(v!); } - if (message.parameter !== '') { + if (message.parameter !== "") { writer.uint32(18).string(message.parameter); } for (const v of message.protoFile) { @@ -229,16 +229,16 @@ export const CodeGeneratorRequest = { if (message.compilerVersion !== undefined) { Version.encode(message.compilerVersion, writer.uint32(26).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -281,12 +281,12 @@ export const CodeGeneratorRequest = { }; function createBaseCodeGeneratorResponse(): CodeGeneratorResponse { - return { error: '', supportedFeatures: 0, file: [] }; + return { error: "", supportedFeatures: 0, file: [] }; } export const CodeGeneratorResponse = { encode(message: CodeGeneratorResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.error !== '') { + if (message.error !== "") { writer.uint32(10).string(message.error); } if (message.supportedFeatures !== 0) { @@ -295,16 +295,16 @@ export const CodeGeneratorResponse = { for (const v of message.file) { CodeGeneratorResponse_File.encode(v!, writer.uint32(122).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -344,33 +344,33 @@ export const CodeGeneratorResponse = { }; function createBaseCodeGeneratorResponse_File(): CodeGeneratorResponse_File { - return { name: '', insertionPoint: '', content: '', generatedCodeInfo: undefined }; + return { name: "", insertionPoint: "", content: "", generatedCodeInfo: undefined }; } export const CodeGeneratorResponse_File = { encode(message: CodeGeneratorResponse_File, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } - if (message.insertionPoint !== '') { + if (message.insertionPoint !== "") { writer.uint32(18).string(message.insertionPoint); } - if (message.content !== '') { + if (message.content !== "") { writer.uint32(122).string(message.content); } if (message.generatedCodeInfo !== undefined) { GeneratedCodeInfo.encode(message.generatedCodeInfo, writer.uint32(130).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -416,16 +416,24 @@ 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'; + 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 longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/unknown-fields/google/protobuf/descriptor.ts b/integration/unknown-fields/google/protobuf/descriptor.ts index 43f507660..86529d1af 100644 --- a/integration/unknown-fields/google/protobuf/descriptor.ts +++ b/integration/unknown-fields/google/protobuf/descriptor.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * The protocol compiler can output a FileDescriptorSet containing the .proto @@ -32,14 +32,18 @@ export interface FileDescriptorProto { enumType: EnumDescriptorProto[]; service: ServiceDescriptorProto[]; extension: FieldDescriptorProto[]; - options: FileOptions | undefined; + options: + | FileOptions + | undefined; /** * This field contains optional information about the original source code. * You may safely remove this entire field without harming runtime * functionality of the descriptors -- the information is needed only by * development tools. */ - sourceCodeInfo: SourceCodeInfo | undefined; + sourceCodeInfo: + | SourceCodeInfo + | undefined; /** * The syntax of the proto file. * The supported values are "proto2" and "proto3". @@ -133,7 +137,9 @@ export interface FieldDescriptorProto { * it to camelCase. */ jsonName: string; - options: FieldOptions | undefined; + options: + | FieldOptions + | undefined; /** * If true, this is a proto3 "optional". When a proto3 field is optional, it * tracks presence regardless of field type. @@ -222,7 +228,9 @@ export interface OneofDescriptorProto { export interface EnumDescriptorProto { name: string; value: EnumValueDescriptorProto[]; - options: EnumOptions | undefined; + options: + | EnumOptions + | undefined; /** * Range of reserved numeric values. Reserved numeric values may not be used * by enum values in the same enum declaration. Reserved ranges may not @@ -274,7 +282,9 @@ export interface MethodDescriptorProto { */ inputType: string; outputType: string; - options: MethodOptions | undefined; + options: + | MethodOptions + | undefined; /** Identifies if client streams multiple client messages */ clientStreaming: boolean; /** Identifies if server streams multiple server messages */ @@ -524,7 +534,6 @@ export interface FieldOptions { * call from multiple threads concurrently, while non-const methods continue * to require exclusive access. * - * * Note that implementations may choose not to check required fields within * a lazy sub-message. That is, calling IsInitialized() on the outer message * may return true even if the inner message has missing required fields. @@ -860,16 +869,16 @@ export const FileDescriptorSet = { for (const v of message.file) { FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -904,8 +913,8 @@ export const FileDescriptorSet = { function createBaseFileDescriptorProto(): FileDescriptorProto { return { - name: '', - package: '', + name: "", + package: "", dependency: [], publicDependency: [], weakDependency: [], @@ -915,16 +924,16 @@ function createBaseFileDescriptorProto(): FileDescriptorProto { extension: [], options: undefined, sourceCodeInfo: undefined, - syntax: '', + syntax: "", }; } export const FileDescriptorProto = { encode(message: FileDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } - if (message.package !== '') { + if (message.package !== "") { writer.uint32(18).string(message.package); } for (const v of message.dependency) { @@ -958,19 +967,19 @@ export const FileDescriptorProto = { if (message.sourceCodeInfo !== undefined) { SourceCodeInfo.encode(message.sourceCodeInfo, writer.uint32(74).fork()).ldelim(); } - if (message.syntax !== '') { + if (message.syntax !== "") { writer.uint32(98).string(message.syntax); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1052,7 +1061,7 @@ export const FileDescriptorProto = { function createBaseDescriptorProto(): DescriptorProto { return { - name: '', + name: "", field: [], extension: [], nestedType: [], @@ -1067,7 +1076,7 @@ function createBaseDescriptorProto(): DescriptorProto { export const DescriptorProto = { encode(message: DescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } for (const v of message.field) { @@ -1097,16 +1106,16 @@ export const DescriptorProto = { for (const v of message.reservedName) { writer.uint32(82).string(v!); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1181,16 +1190,16 @@ export const DescriptorProto_ExtensionRange = { if (message.options !== undefined) { ExtensionRangeOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1241,16 +1250,16 @@ export const DescriptorProto_ReservedRange = { if (message.end !== 0) { writer.uint32(16).int32(message.end); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1295,16 +1304,16 @@ export const ExtensionRangeOptions = { for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1339,15 +1348,15 @@ export const ExtensionRangeOptions = { function createBaseFieldDescriptorProto(): FieldDescriptorProto { return { - name: '', + name: "", number: 0, label: 1, type: 1, - typeName: '', - extendee: '', - defaultValue: '', + typeName: "", + extendee: "", + defaultValue: "", oneofIndex: 0, - jsonName: '', + jsonName: "", options: undefined, proto3Optional: false, }; @@ -1355,7 +1364,7 @@ function createBaseFieldDescriptorProto(): FieldDescriptorProto { export const FieldDescriptorProto = { encode(message: FieldDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.number !== 0) { @@ -1367,19 +1376,19 @@ export const FieldDescriptorProto = { if (message.type !== 1) { writer.uint32(40).int32(message.type); } - if (message.typeName !== '') { + if (message.typeName !== "") { writer.uint32(50).string(message.typeName); } - if (message.extendee !== '') { + if (message.extendee !== "") { writer.uint32(18).string(message.extendee); } - if (message.defaultValue !== '') { + if (message.defaultValue !== "") { writer.uint32(58).string(message.defaultValue); } if (message.oneofIndex !== 0) { writer.uint32(72).int32(message.oneofIndex); } - if (message.jsonName !== '') { + if (message.jsonName !== "") { writer.uint32(82).string(message.jsonName); } if (message.options !== undefined) { @@ -1388,16 +1397,16 @@ export const FieldDescriptorProto = { if (message.proto3Optional === true) { writer.uint32(136).bool(message.proto3Optional); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1461,27 +1470,27 @@ export const FieldDescriptorProto = { }; function createBaseOneofDescriptorProto(): OneofDescriptorProto { - return { name: '', options: undefined }; + return { name: "", options: undefined }; } export const OneofDescriptorProto = { encode(message: OneofDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.options !== undefined) { OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1518,12 +1527,12 @@ export const OneofDescriptorProto = { }; function createBaseEnumDescriptorProto(): EnumDescriptorProto { - return { name: '', value: [], options: undefined, reservedRange: [], reservedName: [] }; + return { name: "", value: [], options: undefined, reservedRange: [], reservedName: [] }; } export const EnumDescriptorProto = { encode(message: EnumDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } for (const v of message.value) { @@ -1538,16 +1547,16 @@ export const EnumDescriptorProto = { for (const v of message.reservedName) { writer.uint32(42).string(v!); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1604,16 +1613,16 @@ export const EnumDescriptorProto_EnumReservedRange = { if (message.end !== 0) { writer.uint32(16).int32(message.end); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1650,12 +1659,12 @@ export const EnumDescriptorProto_EnumReservedRange = { }; function createBaseEnumValueDescriptorProto(): EnumValueDescriptorProto { - return { name: '', number: 0, options: undefined }; + return { name: "", number: 0, options: undefined }; } export const EnumValueDescriptorProto = { encode(message: EnumValueDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.number !== 0) { @@ -1664,16 +1673,16 @@ export const EnumValueDescriptorProto = { if (message.options !== undefined) { EnumValueOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1713,12 +1722,12 @@ export const EnumValueDescriptorProto = { }; function createBaseServiceDescriptorProto(): ServiceDescriptorProto { - return { name: '', method: [], options: undefined }; + return { name: "", method: [], options: undefined }; } export const ServiceDescriptorProto = { encode(message: ServiceDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } for (const v of message.method) { @@ -1727,16 +1736,16 @@ export const ServiceDescriptorProto = { if (message.options !== undefined) { ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1777,9 +1786,9 @@ export const ServiceDescriptorProto = { function createBaseMethodDescriptorProto(): MethodDescriptorProto { return { - name: '', - inputType: '', - outputType: '', + name: "", + inputType: "", + outputType: "", options: undefined, clientStreaming: false, serverStreaming: false, @@ -1788,13 +1797,13 @@ function createBaseMethodDescriptorProto(): MethodDescriptorProto { export const MethodDescriptorProto = { encode(message: MethodDescriptorProto, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } - if (message.inputType !== '') { + if (message.inputType !== "") { writer.uint32(18).string(message.inputType); } - if (message.outputType !== '') { + if (message.outputType !== "") { writer.uint32(26).string(message.outputType); } if (message.options !== undefined) { @@ -1806,16 +1815,16 @@ export const MethodDescriptorProto = { if (message.serverStreaming === true) { writer.uint32(48).bool(message.serverStreaming); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -1865,36 +1874,36 @@ export const MethodDescriptorProto = { function createBaseFileOptions(): FileOptions { return { - javaPackage: '', - javaOuterClassname: '', + javaPackage: "", + javaOuterClassname: "", javaMultipleFiles: false, javaGenerateEqualsAndHash: false, javaStringCheckUtf8: false, optimizeFor: 1, - goPackage: '', + goPackage: "", ccGenericServices: false, javaGenericServices: false, pyGenericServices: false, phpGenericServices: false, deprecated: false, ccEnableArenas: false, - objcClassPrefix: '', - csharpNamespace: '', - swiftPrefix: '', - phpClassPrefix: '', - phpNamespace: '', - phpMetadataNamespace: '', - rubyPackage: '', + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", uninterpretedOption: [], }; } export const FileOptions = { encode(message: FileOptions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.javaPackage !== '') { + if (message.javaPackage !== "") { writer.uint32(10).string(message.javaPackage); } - if (message.javaOuterClassname !== '') { + if (message.javaOuterClassname !== "") { writer.uint32(66).string(message.javaOuterClassname); } if (message.javaMultipleFiles === true) { @@ -1909,7 +1918,7 @@ export const FileOptions = { if (message.optimizeFor !== 1) { writer.uint32(72).int32(message.optimizeFor); } - if (message.goPackage !== '') { + if (message.goPackage !== "") { writer.uint32(90).string(message.goPackage); } if (message.ccGenericServices === true) { @@ -1930,40 +1939,40 @@ export const FileOptions = { if (message.ccEnableArenas === true) { writer.uint32(248).bool(message.ccEnableArenas); } - if (message.objcClassPrefix !== '') { + if (message.objcClassPrefix !== "") { writer.uint32(290).string(message.objcClassPrefix); } - if (message.csharpNamespace !== '') { + if (message.csharpNamespace !== "") { writer.uint32(298).string(message.csharpNamespace); } - if (message.swiftPrefix !== '') { + if (message.swiftPrefix !== "") { writer.uint32(314).string(message.swiftPrefix); } - if (message.phpClassPrefix !== '') { + if (message.phpClassPrefix !== "") { writer.uint32(322).string(message.phpClassPrefix); } - if (message.phpNamespace !== '') { + if (message.phpNamespace !== "") { writer.uint32(330).string(message.phpNamespace); } - if (message.phpMetadataNamespace !== '') { + if (message.phpMetadataNamespace !== "") { writer.uint32(354).string(message.phpMetadataNamespace); } - if (message.rubyPackage !== '') { + if (message.rubyPackage !== "") { writer.uint32(362).string(message.rubyPackage); } for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2083,16 +2092,16 @@ export const MessageOptions = { for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2164,16 +2173,16 @@ export const FieldOptions = { for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2233,16 +2242,16 @@ export const OneofOptions = { for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2290,16 +2299,16 @@ export const EnumOptions = { for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2350,16 +2359,16 @@ export const EnumValueOptions = { for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2407,16 +2416,16 @@ export const ServiceOptions = { for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2467,16 +2476,16 @@ export const MethodOptions = { for (const v of message.uninterpretedOption) { UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2518,12 +2527,12 @@ export const MethodOptions = { function createBaseUninterpretedOption(): UninterpretedOption { return { name: [], - identifierValue: '', + identifierValue: "", positiveIntValue: 0, negativeIntValue: 0, doubleValue: 0, stringValue: new Uint8Array(), - aggregateValue: '', + aggregateValue: "", }; } @@ -2532,7 +2541,7 @@ export const UninterpretedOption = { for (const v of message.name) { UninterpretedOption_NamePart.encode(v!, writer.uint32(18).fork()).ldelim(); } - if (message.identifierValue !== '') { + if (message.identifierValue !== "") { writer.uint32(26).string(message.identifierValue); } if (message.positiveIntValue !== 0) { @@ -2547,19 +2556,19 @@ export const UninterpretedOption = { if (message.stringValue.length !== 0) { writer.uint32(58).bytes(message.stringValue); } - if (message.aggregateValue !== '') { + if (message.aggregateValue !== "") { writer.uint32(66).string(message.aggregateValue); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2611,27 +2620,27 @@ export const UninterpretedOption = { }; function createBaseUninterpretedOption_NamePart(): UninterpretedOption_NamePart { - return { namePart: '', isExtension: false }; + return { namePart: "", isExtension: false }; } export const UninterpretedOption_NamePart = { encode(message: UninterpretedOption_NamePart, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.namePart !== '') { + if (message.namePart !== "") { writer.uint32(10).string(message.namePart); } if (message.isExtension === true) { writer.uint32(16).bool(message.isExtension); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2676,16 +2685,16 @@ export const SourceCodeInfo = { for (const v of message.location) { SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2719,7 +2728,7 @@ export const SourceCodeInfo = { }; function createBaseSourceCodeInfo_Location(): SourceCodeInfo_Location { - return { path: [], span: [], leadingComments: '', trailingComments: '', leadingDetachedComments: [] }; + return { path: [], span: [], leadingComments: "", trailingComments: "", leadingDetachedComments: [] }; } export const SourceCodeInfo_Location = { @@ -2734,25 +2743,25 @@ export const SourceCodeInfo_Location = { writer.int32(v); } writer.ldelim(); - if (message.leadingComments !== '') { + if (message.leadingComments !== "") { writer.uint32(26).string(message.leadingComments); } - if (message.trailingComments !== '') { + if (message.trailingComments !== "") { writer.uint32(34).string(message.trailingComments); } for (const v of message.leadingDetachedComments) { writer.uint32(50).string(v!); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2820,16 +2829,16 @@ export const GeneratedCodeInfo = { for (const v of message.annotation) { GeneratedCodeInfo_Annotation.encode(v!, writer.uint32(10).fork()).ldelim(); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2863,7 +2872,7 @@ export const GeneratedCodeInfo = { }; function createBaseGeneratedCodeInfo_Annotation(): GeneratedCodeInfo_Annotation { - return { path: [], sourceFile: '', begin: 0, end: 0 }; + return { path: [], sourceFile: "", begin: 0, end: 0 }; } export const GeneratedCodeInfo_Annotation = { @@ -2873,7 +2882,7 @@ export const GeneratedCodeInfo_Annotation = { writer.int32(v); } writer.ldelim(); - if (message.sourceFile !== '') { + if (message.sourceFile !== "") { writer.uint32(18).string(message.sourceFile); } if (message.begin !== 0) { @@ -2882,16 +2891,16 @@ export const GeneratedCodeInfo_Annotation = { if (message.end !== 0) { writer.uint32(32).int32(message.end); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -2944,16 +2953,24 @@ 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'; + 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 longToNumber(long: Long): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { - throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/unknown-fields/options.ts b/integration/unknown-fields/options.ts index 0a2448879..fb0869ba5 100644 --- a/integration/unknown-fields/options.ts +++ b/integration/unknown-fields/options.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export enum MyEnum { FOO = 0, @@ -16,9 +16,11 @@ export interface MyMessage { quux: string | undefined; } -export interface RequestType {} +export interface RequestType { +} -export interface ResponseType {} +export interface ResponseType { +} function createBaseMyMessage(): MyMessage { return { foo: undefined, foo2: undefined, bar: undefined, quux: undefined }; @@ -38,16 +40,16 @@ export const MyMessage = { if (message.quux !== undefined) { writer.uint32(34).string(message.quux); } - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -95,16 +97,16 @@ function createBaseRequestType(): RequestType { export const RequestType = { encode(message: RequestType, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -140,16 +142,16 @@ function createBaseResponseType(): ResponseType { export const ResponseType = { encode(message: ResponseType, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } @@ -191,7 +193,7 @@ export class MyServiceClientImpl implements MyService { } MyMethod(request: RequestType): Promise { const data = RequestType.encode(request).finish(); - const promise = this.rpc.request('MyService', 'MyMethod', data); + const promise = this.rpc.request("MyService", "MyMethod", data); return promise.then((data) => ResponseType.decode(new _m0.Reader(data))); } } diff --git a/integration/unknown-fields/something/something.ts b/integration/unknown-fields/something/something.ts index 95840185f..2ce718a3f 100644 --- a/integration/unknown-fields/something/something.ts +++ b/integration/unknown-fields/something/something.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'something'; +export const protobufPackage = "something"; export interface Something { hello: string; @@ -9,12 +9,12 @@ export interface Something { } function createBaseSomething(): Something { - return { hello: '', foo: [] }; + return { hello: "", foo: [] }; } export const Something = { encode(message: Something, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.hello !== '') { + if (message.hello !== "") { writer.uint32(10).string(message.hello); } writer.uint32(18).fork(); @@ -22,16 +22,16 @@ export const Something = { writer.int32(v); } writer.ldelim(); - if ('_unknownFields' in message) { - const msgUnknownFields: any = (message as any)['_unknownFields']; + if ("_unknownFields" in message) { + const msgUnknownFields: any = (message as any)["_unknownFields"]; for (const key of Object.keys(msgUnknownFields)) { const values = msgUnknownFields[key] as Uint8Array[]; for (const value of values) { writer.uint32(parseInt(key, 10)); - (writer as any)['_push']( + (writer as any)["_push"]( (val: Uint8Array, buf: Buffer, pos: number) => buf.set(val, pos), value.length, - value + value, ); } } diff --git a/integration/use-date-false/google/protobuf/timestamp.ts b/integration/use-date-false/google/protobuf/timestamp.ts index c52fb2549..5497f7183 100644 --- a/integration/use-date-false/google/protobuf/timestamp.ts +++ b/integration/use-date-false/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/use-date-false/metadata.ts b/integration/use-date-false/metadata.ts index 70ff80e07..4bffb848d 100644 --- a/integration/use-date-false/metadata.ts +++ b/integration/use-date-false/metadata.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { Timestamp } from './google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface Metadata { lastEdited: Timestamp | undefined; @@ -39,9 +39,7 @@ export const Metadata = { }, fromJSON(object: any): Metadata { - return { - lastEdited: isSet(object.lastEdited) ? fromJsonTimestamp(object.lastEdited) : undefined, - }; + return { lastEdited: isSet(object.lastEdited) ? fromJsonTimestamp(object.lastEdited) : undefined }; }, toJSON(message: Metadata): unknown { @@ -52,29 +50,22 @@ export const Metadata = { fromPartial, I>>(object: I): Metadata { const message = createBaseMetadata(); - message.lastEdited = - object.lastEdited !== undefined && object.lastEdited !== null - ? Timestamp.fromPartial(object.lastEdited) - : undefined; + message.lastEdited = (object.lastEdited !== undefined && object.lastEdited !== null) + ? Timestamp.fromPartial(object.lastEdited) + : undefined; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -92,7 +83,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Timestamp { if (o instanceof Date) { return toTimestamp(o); - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return toTimestamp(new Date(o)); } else { return Timestamp.fromJSON(o); diff --git a/integration/use-date-string/google/protobuf/timestamp.ts b/integration/use-date-string/google/protobuf/timestamp.ts index c52fb2549..5497f7183 100644 --- a/integration/use-date-string/google/protobuf/timestamp.ts +++ b/integration/use-date-string/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/use-date-string/use-date-string.ts b/integration/use-date-string/use-date-string.ts index d9b0fb599..62c6e70e5 100644 --- a/integration/use-date-string/use-date-string.ts +++ b/integration/use-date-string/use-date-string.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { Timestamp } from './google/protobuf/timestamp'; -import * as _m0 from 'protobufjs/minimal'; +import { Timestamp } from "./google/protobuf/timestamp"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface Todo { id: string; @@ -18,12 +18,12 @@ export interface Todo_MapOfTimestampsEntry { } function createBaseTodo(): Todo { - return { id: '', timestamp: undefined, repeatedTimestamp: [], optionalTimestamp: undefined, mapOfTimestamps: {} }; + return { id: "", timestamp: undefined, repeatedTimestamp: [], optionalTimestamp: undefined, mapOfTimestamps: {} }; } export const Todo = { encode(message: Todo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== '') { + if (message.id !== "") { writer.uint32(10).string(message.id); } if (message.timestamp !== undefined) { @@ -76,7 +76,7 @@ export const Todo = { fromJSON(object: any): Todo { return { - id: isSet(object.id) ? String(object.id) : '', + id: isSet(object.id) ? String(object.id) : "", timestamp: isSet(object.timestamp) ? String(object.timestamp) : undefined, repeatedTimestamp: Array.isArray(object?.repeatedTimestamp) ? object.repeatedTimestamp.map((e: any) => String(e)) @@ -84,9 +84,9 @@ export const Todo = { optionalTimestamp: isSet(object.optionalTimestamp) ? String(object.optionalTimestamp) : undefined, mapOfTimestamps: isObject(object.mapOfTimestamps) ? Object.entries(object.mapOfTimestamps).reduce<{ [key: string]: string }>((acc, [key, value]) => { - acc[key] = String(value); - return acc; - }, {}) + acc[key] = String(value); + return acc; + }, {}) : {}, }; }, @@ -112,7 +112,7 @@ export const Todo = { fromPartial, I>>(object: I): Todo { const message = createBaseTodo(); - message.id = object.id ?? ''; + message.id = object.id ?? ""; message.timestamp = object.timestamp ?? undefined; message.repeatedTimestamp = object.repeatedTimestamp?.map((e) => e) || []; message.optionalTimestamp = object.optionalTimestamp ?? undefined; @@ -123,19 +123,19 @@ export const Todo = { } return acc; }, - {} + {}, ); return message; }, }; function createBaseTodo_MapOfTimestampsEntry(): Todo_MapOfTimestampsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Todo_MapOfTimestampsEntry = { encode(message: Todo_MapOfTimestampsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -167,7 +167,7 @@ export const Todo_MapOfTimestampsEntry = { fromJSON(object: any): Todo_MapOfTimestampsEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : undefined, }; }, @@ -181,7 +181,7 @@ export const Todo_MapOfTimestampsEntry = { fromPartial, I>>(object: I): Todo_MapOfTimestampsEntry { const message = createBaseTodo_MapOfTimestampsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -189,19 +189,13 @@ export const Todo_MapOfTimestampsEntry = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(dateStr: string): Timestamp { @@ -218,7 +212,7 @@ function fromTimestamp(t: Timestamp): string { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/use-date-true/google/protobuf/empty.ts b/integration/use-date-true/google/protobuf/empty.ts index 4e15078f1..4318905c6 100644 --- a/integration/use-date-true/google/protobuf/empty.ts +++ b/integration/use-date-true/google/protobuf/empty.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A generic empty message that you can re-use to avoid defining duplicated @@ -14,7 +14,8 @@ export const protobufPackage = 'google.protobuf'; * * The JSON representation for `Empty` is empty JSON object `{}`. */ -export interface Empty {} +export interface Empty { +} function createBaseEmpty(): Empty { return {}; @@ -57,17 +58,11 @@ export const Empty = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; diff --git a/integration/use-date-true/google/protobuf/timestamp.ts b/integration/use-date-true/google/protobuf/timestamp.ts index c52fb2549..5497f7183 100644 --- a/integration/use-date-true/google/protobuf/timestamp.ts +++ b/integration/use-date-true/google/protobuf/timestamp.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -55,7 +55,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -64,7 +63,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() @@ -175,33 +173,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/use-date-true/use-date-true.ts b/integration/use-date-true/use-date-true.ts index b4bceee9f..56cd91148 100644 --- a/integration/use-date-true/use-date-true.ts +++ b/integration/use-date-true/use-date-true.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import { Timestamp } from './google/protobuf/timestamp'; -import { Empty } from './google/protobuf/empty'; -import * as _m0 from 'protobufjs/minimal'; +import { Timestamp } from "./google/protobuf/timestamp"; +import { Empty } from "./google/protobuf/empty"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface Todo { id: string; @@ -19,12 +19,12 @@ export interface Todo_MapOfTimestampsEntry { } function createBaseTodo(): Todo { - return { id: '', timestamp: undefined, repeatedTimestamp: [], optionalTimestamp: undefined, mapOfTimestamps: {} }; + return { id: "", timestamp: undefined, repeatedTimestamp: [], optionalTimestamp: undefined, mapOfTimestamps: {} }; } export const Todo = { encode(message: Todo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== '') { + if (message.id !== "") { writer.uint32(10).string(message.id); } if (message.timestamp !== undefined) { @@ -77,7 +77,7 @@ export const Todo = { fromJSON(object: any): Todo { return { - id: isSet(object.id) ? String(object.id) : '', + id: isSet(object.id) ? String(object.id) : "", timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined, repeatedTimestamp: Array.isArray(object?.repeatedTimestamp) ? object.repeatedTimestamp.map((e: any) => fromJsonTimestamp(e)) @@ -85,9 +85,9 @@ export const Todo = { optionalTimestamp: isSet(object.optionalTimestamp) ? fromJsonTimestamp(object.optionalTimestamp) : undefined, mapOfTimestamps: isObject(object.mapOfTimestamps) ? Object.entries(object.mapOfTimestamps).reduce<{ [key: string]: Date }>((acc, [key, value]) => { - acc[key] = fromJsonTimestamp(value); - return acc; - }, {}) + acc[key] = fromJsonTimestamp(value); + return acc; + }, {}) : {}, }; }, @@ -113,7 +113,7 @@ export const Todo = { fromPartial, I>>(object: I): Todo { const message = createBaseTodo(); - message.id = object.id ?? ''; + message.id = object.id ?? ""; message.timestamp = object.timestamp ?? undefined; message.repeatedTimestamp = object.repeatedTimestamp?.map((e) => e) || []; message.optionalTimestamp = object.optionalTimestamp ?? undefined; @@ -124,19 +124,19 @@ export const Todo = { } return acc; }, - {} + {}, ); return message; }, }; function createBaseTodo_MapOfTimestampsEntry(): Todo_MapOfTimestampsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Todo_MapOfTimestampsEntry = { encode(message: Todo_MapOfTimestampsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -168,7 +168,7 @@ export const Todo_MapOfTimestampsEntry = { fromJSON(object: any): Todo_MapOfTimestampsEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? fromJsonTimestamp(object.value) : undefined, }; }, @@ -182,7 +182,7 @@ export const Todo_MapOfTimestampsEntry = { fromPartial, I>>(object: I): Todo_MapOfTimestampsEntry { const message = createBaseTodo_MapOfTimestampsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -200,18 +200,18 @@ export class ClockClientImpl implements Clock { } Now(request: Empty): Promise { const data = Empty.encode(request).finish(); - const promise = this.rpc.request('Clock', 'Now', data); + const promise = this.rpc.request("Clock", "Now", data); return promise.then((data) => fromTimestamp(Timestamp.decode(new _m0.Reader(data)))); } } export type ClockDefinition = typeof ClockDefinition; export const ClockDefinition = { - name: 'Clock', - fullName: 'Clock', + name: "Clock", + fullName: "Clock", methods: { now: { - name: 'Now', + name: "Now", requestType: Empty, requestStream: false, responseType: Timestamp, @@ -227,19 +227,13 @@ interface Rpc { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function toTimestamp(date: Date): Timestamp { @@ -257,7 +251,7 @@ function fromTimestamp(t: Timestamp): Date { function fromJsonTimestamp(o: any): Date { if (o instanceof Date) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new Date(o); } else { return fromTimestamp(Timestamp.fromJSON(o)); @@ -265,7 +259,7 @@ function fromJsonTimestamp(o: any): Date { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/use-exact-types-false/foo.ts b/integration/use-exact-types-false/foo.ts index b5c5b40b1..59171cb9d 100644 --- a/integration/use-exact-types-false/foo.ts +++ b/integration/use-exact-types-false/foo.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'foo'; +export const protobufPackage = "foo"; export interface Foo { bar: string; @@ -9,15 +9,15 @@ export interface Foo { } function createBaseFoo(): Foo { - return { bar: '', baz: '' }; + return { bar: "", baz: "" }; } export const Foo = { encode(message: Foo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.bar !== '') { + if (message.bar !== "") { writer.uint32(10).string(message.bar); } - if (message.baz !== '') { + if (message.baz !== "") { writer.uint32(18).string(message.baz); } return writer; @@ -45,10 +45,7 @@ export const Foo = { }, fromJSON(object: any): Foo { - return { - bar: isSet(object.bar) ? String(object.bar) : '', - baz: isSet(object.baz) ? String(object.baz) : '', - }; + return { bar: isSet(object.bar) ? String(object.bar) : "", baz: isSet(object.baz) ? String(object.baz) : "" }; }, toJSON(message: Foo): unknown { @@ -60,22 +57,17 @@ export const Foo = { fromPartial(object: DeepPartial): Foo { const message = createBaseFoo(); - message.bar = object.bar ?? ''; - message.baz = object.baz ?? ''; + message.bar = object.bar ?? ""; + message.baz = object.baz ?? ""; 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 } +export type DeepPartial = T extends Builtin ? T + : T extends Array ? Array> : T extends ReadonlyArray ? ReadonlyArray> + : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; function isSet(value: any): boolean { diff --git a/integration/use-json-wire-format/google/protobuf/duration.ts b/integration/use-json-wire-format/google/protobuf/duration.ts index 003dbf46e..7a003b5e8 100644 --- a/integration/use-json-wire-format/google/protobuf/duration.ts +++ b/integration/use-json-wire-format/google/protobuf/duration.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Duration represents a signed, fixed-length span of time represented diff --git a/integration/use-json-wire-format/google/protobuf/field_mask.ts b/integration/use-json-wire-format/google/protobuf/field_mask.ts index f33e4ce2e..bbb342d8d 100644 --- a/integration/use-json-wire-format/google/protobuf/field_mask.ts +++ b/integration/use-json-wire-format/google/protobuf/field_mask.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `FieldMask` represents a set of symbolic field paths, for example: @@ -36,7 +36,6 @@ export const protobufPackage = 'google.protobuf'; * (their value will be set to the default, and omitted in proto text * output): * - * * f { * a : 22 * b { diff --git a/integration/use-json-wire-format/google/protobuf/timestamp.ts b/integration/use-json-wire-format/google/protobuf/timestamp.ts index fe2ef4bac..98330174a 100644 --- a/integration/use-json-wire-format/google/protobuf/timestamp.ts +++ b/integration/use-json-wire-format/google/protobuf/timestamp.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * A Timestamp represents a point in time independent of any time zone or local @@ -52,7 +52,6 @@ export const protobufPackage = 'google.protobuf'; * 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(); @@ -61,7 +60,6 @@ export const protobufPackage = 'google.protobuf'; * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) * .setNanos(now.getNano()).build(); * - * * Example 6: Compute Timestamp from current time in Python. * * timestamp = Timestamp() diff --git a/integration/use-json-wire-format/use-json-wire-format.ts b/integration/use-json-wire-format/use-json-wire-format.ts index 64f67634f..e8ca4cdfe 100644 --- a/integration/use-json-wire-format/use-json-wire-format.ts +++ b/integration/use-json-wire-format/use-json-wire-format.ts @@ -1,5 +1,5 @@ /* eslint-disable */ -export const protobufPackage = ''; +export const protobufPackage = ""; export interface Todo { id?: string; diff --git a/integration/use-numeric-enum-json/google/protobuf/struct.ts b/integration/use-numeric-enum-json/google/protobuf/struct.ts index f381a41bf..d17382273 100644 --- a/integration/use-numeric-enum-json/google/protobuf/struct.ts +++ b/integration/use-numeric-enum-json/google/protobuf/struct.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the @@ -18,10 +18,10 @@ export enum NullValue { export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: - case 'NULL_VALUE': + case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } @@ -67,15 +67,25 @@ export interface Struct_FieldsEntry { */ export interface Value { /** Represents a null value. */ - nullValue: NullValue | undefined; + nullValue: + | NullValue + | undefined; /** Represents a double value. */ - numberValue: number | undefined; + numberValue: + | number + | undefined; /** Represents a string value. */ - stringValue: string | undefined; + stringValue: + | string + | undefined; /** Represents a boolean value. */ - boolValue: boolean | undefined; + boolValue: + | boolean + | undefined; /** Represents a structured value. */ - structValue: { [key: string]: any } | undefined; + structValue: + | { [key: string]: any } + | undefined; /** Represents a repeated `Value`. */ listValue: Array | undefined; } @@ -129,9 +139,9 @@ export const 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; - }, {}) + acc[key] = value as any | undefined; + return acc; + }, {}) : {}, }; }, @@ -156,7 +166,7 @@ export const Struct = { } return acc; }, - {} + {}, ); return message; }, @@ -181,12 +191,12 @@ export const Struct = { }; function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Struct_FieldsEntry = { encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -217,10 +227,7 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object?.value) ? object.value : undefined, - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -232,7 +239,7 @@ export const Struct_FieldsEntry = { fromPartial, I>>(object: I): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -344,18 +351,18 @@ export const Value = { if (value === null) { result.nullValue = NullValue.NULL_VALUE; - } else if (typeof value === 'boolean') { + } else if (typeof value === "boolean") { result.boolValue = value; - } else if (typeof value === 'number') { + } else if (typeof value === "number") { result.numberValue = value; - } else if (typeof value === 'string') { + } else if (typeof value === "string") { result.stringValue = value; } else if (Array.isArray(value)) { result.listValue = value; - } else if (typeof value === 'object') { + } else if (typeof value === "object") { result.structValue = value; - } else if (typeof value !== 'undefined') { - throw new Error('Unsupported any value type: ' + typeof value); + } else if (typeof value !== "undefined") { + throw new Error("Unsupported any value type: " + typeof value); } return result; @@ -410,9 +417,7 @@ export const ListValue = { }, fromJSON(object: any): ListValue { - return { - values: Array.isArray(object?.values) ? [...object.values] : [], - }; + return { values: Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { @@ -446,23 +451,17 @@ export const 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/use-numeric-enum-json/simple.ts b/integration/use-numeric-enum-json/simple.ts index 25e57b03a..0e7924be7 100644 --- a/integration/use-numeric-enum-json/simple.ts +++ b/integration/use-numeric-enum-json/simple.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import { NullValue, nullValueFromJSON, nullValueToJSON } from './google/protobuf/struct'; -import * as _m0 from 'protobufjs/minimal'; +import { NullValue, nullValueFromJSON, nullValueToJSON } from "./google/protobuf/struct"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'simple'; +export const protobufPackage = "simple"; export enum StateEnum { UNKNOWN = 0, @@ -14,16 +14,16 @@ export enum StateEnum { export function stateEnumFromJSON(object: any): StateEnum { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return StateEnum.UNKNOWN; case 2: - case 'ON': + case "ON": return StateEnum.ON; case 3: - case 'OFF': + case "OFF": return StateEnum.OFF; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return StateEnum.UNRECOGNIZED; } @@ -57,12 +57,12 @@ export interface Simple_StateMapEntry { } function createBaseSimple(): Simple { - return { name: '', state: 0, states: [], nullValue: 0, stateMap: {} }; + return { name: "", state: 0, states: [], nullValue: 0, stateMap: {} }; } export const Simple = { encode(message: Simple, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.state !== 0) { @@ -124,15 +124,15 @@ export const Simple = { fromJSON(object: any): Simple { return { - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0, states: Array.isArray(object?.states) ? object.states.map((e: any) => stateEnumFromJSON(e)) : [], nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : 0, stateMap: isObject(object.stateMap) ? Object.entries(object.stateMap).reduce<{ [key: string]: StateEnum }>((acc, [key, value]) => { - acc[key] = stateEnumFromJSON(value); - return acc; - }, {}) + acc[key] = stateEnumFromJSON(value); + return acc; + }, {}) : {}, }; }, @@ -158,7 +158,7 @@ export const Simple = { fromPartial, I>>(object: I): Simple { const message = createBaseSimple(); - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.state = object.state ?? 0; message.states = object.states?.map((e) => e) || []; message.nullValue = object.nullValue ?? 0; @@ -169,19 +169,19 @@ export const Simple = { } return acc; }, - {} + {}, ); return message; }, }; function createBaseSimple_StateMapEntry(): Simple_StateMapEntry { - return { key: '', value: 0 }; + return { key: "", value: 0 }; } export const Simple_StateMapEntry = { encode(message: Simple_StateMapEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== 0) { @@ -213,7 +213,7 @@ export const Simple_StateMapEntry = { fromJSON(object: any): Simple_StateMapEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? stateEnumFromJSON(object.value) : 0, }; }, @@ -227,7 +227,7 @@ export const Simple_StateMapEntry = { fromPartial, I>>(object: I): Simple_StateMapEntry { const message = createBaseSimple_StateMapEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? 0; return message; }, @@ -235,23 +235,17 @@ export const Simple_StateMapEntry = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/use-objectid-true-external-import/objectid/objectid.ts b/integration/use-objectid-true-external-import/objectid/objectid.ts index f152a2448..176cf27c6 100644 --- a/integration/use-objectid-true-external-import/objectid/objectid.ts +++ b/integration/use-objectid-true-external-import/objectid/objectid.ts @@ -1,19 +1,19 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'foo.objectid'; +export const protobufPackage = "foo.objectid"; export interface ObjectId { value: string; } function createBaseObjectId(): ObjectId { - return { value: '' }; + return { value: "" }; } export const ObjectId = { encode(message: ObjectId, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -38,9 +38,7 @@ export const ObjectId = { }, fromJSON(object: any): ObjectId { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: ObjectId): unknown { @@ -51,26 +49,20 @@ export const ObjectId = { fromPartial, I>>(object: I): ObjectId { const message = createBaseObjectId(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isSet(value: any): boolean { diff --git a/integration/use-objectid-true-external-import/use-objectid-true.ts b/integration/use-objectid-true-external-import/use-objectid-true.ts index 2bf250bf3..83d4db1fc 100644 --- a/integration/use-objectid-true-external-import/use-objectid-true.ts +++ b/integration/use-objectid-true-external-import/use-objectid-true.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import * as mongodb from 'mongodb'; -import * as _m0 from 'protobufjs/minimal'; -import { ObjectId } from './objectid/objectid'; +import * as mongodb from "mongodb"; +import * as _m0 from "protobufjs/minimal"; +import { ObjectId } from "./objectid/objectid"; -export const protobufPackage = 'foo'; +export const protobufPackage = "foo"; export interface Todo { id: string; @@ -19,12 +19,12 @@ export interface Todo_MapOfOidsEntry { } function createBaseTodo(): Todo { - return { id: '', oid: undefined, repeatedOid: [], optionalOid: undefined, mapOfOids: {} }; + return { id: "", oid: undefined, repeatedOid: [], optionalOid: undefined, mapOfOids: {} }; } export const Todo = { encode(message: Todo, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.id !== '') { + if (message.id !== "") { writer.uint32(10).string(message.id); } if (message.oid !== undefined) { @@ -77,15 +77,15 @@ export const Todo = { fromJSON(object: any): Todo { return { - id: isSet(object.id) ? String(object.id) : '', + id: isSet(object.id) ? String(object.id) : "", oid: isSet(object.oid) ? fromJsonObjectId(object.oid) : undefined, repeatedOid: Array.isArray(object?.repeatedOid) ? object.repeatedOid.map((e: any) => fromJsonObjectId(e)) : [], optionalOid: isSet(object.optionalOid) ? fromJsonObjectId(object.optionalOid) : undefined, mapOfOids: isObject(object.mapOfOids) ? Object.entries(object.mapOfOids).reduce<{ [key: string]: mongodb.ObjectId }>((acc, [key, value]) => { - acc[key] = fromJsonObjectId(value); - return acc; - }, {}) + acc[key] = fromJsonObjectId(value); + return acc; + }, {}) : {}, }; }, @@ -111,13 +111,12 @@ export const Todo = { fromPartial, I>>(object: I): Todo { const message = createBaseTodo(); - message.id = object.id ?? ''; - message.oid = object.oid !== undefined && object.oid !== null ? (object.oid as mongodb.ObjectId) : undefined; + message.id = object.id ?? ""; + message.oid = (object.oid !== undefined && object.oid !== null) ? object.oid as mongodb.ObjectId : undefined; message.repeatedOid = object.repeatedOid?.map((e) => e as mongodb.ObjectId) || []; - message.optionalOid = - object.optionalOid !== undefined && object.optionalOid !== null - ? (object.optionalOid as mongodb.ObjectId) - : undefined; + message.optionalOid = (object.optionalOid !== undefined && object.optionalOid !== null) + ? object.optionalOid as mongodb.ObjectId + : undefined; message.mapOfOids = Object.entries(object.mapOfOids ?? {}).reduce<{ [key: string]: mongodb.ObjectId }>( (acc, [key, value]) => { if (value !== undefined) { @@ -125,19 +124,19 @@ export const Todo = { } return acc; }, - {} + {}, ); return message; }, }; function createBaseTodo_MapOfOidsEntry(): Todo_MapOfOidsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Todo_MapOfOidsEntry = { encode(message: Todo_MapOfOidsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -169,7 +168,7 @@ export const Todo_MapOfOidsEntry = { fromJSON(object: any): Todo_MapOfOidsEntry { return { - key: isSet(object.key) ? String(object.key) : '', + key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? fromJsonObjectId(object.value) : undefined, }; }, @@ -183,34 +182,29 @@ export const Todo_MapOfOidsEntry = { fromPartial, I>>(object: I): Todo_MapOfOidsEntry { const message = createBaseTodo_MapOfOidsEntry(); - message.key = object.key ?? ''; - message.value = - object.value !== undefined && object.value !== null ? (object.value as mongodb.ObjectId) : undefined; + message.key = object.key ?? ""; + message.value = (object.value !== undefined && object.value !== null) + ? object.value as mongodb.ObjectId + : undefined; 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function fromJsonObjectId(o: any): mongodb.ObjectId { if (o instanceof mongodb.ObjectId) { return o; - } else if (typeof o === 'string') { + } else if (typeof o === "string") { return new mongodb.ObjectId(o); } else { return fromProtoObjectId(ObjectId.fromJSON(o)); @@ -227,7 +221,7 @@ function toProtoObjectId(oid: mongodb.ObjectId): ObjectId { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/use-optionals-all/test.ts b/integration/use-optionals-all/test.ts index 5135161f9..3cf686dd6 100644 --- a/integration/use-optionals-all/test.ts +++ b/integration/use-optionals-all/test.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'optionalstest'; +export const protobufPackage = "optionalstest"; export enum StateEnum { UNKNOWN = 0, @@ -14,16 +14,16 @@ export enum StateEnum { export function stateEnumFromJSON(object: any): StateEnum { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return StateEnum.UNKNOWN; case 2: - case 'ON': + case "ON": return StateEnum.ON; case 3: - case 'OFF': + case "OFF": return StateEnum.OFF; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return StateEnum.UNRECOGNIZED; } @@ -32,14 +32,14 @@ export function stateEnumFromJSON(object: any): StateEnum { export function stateEnumToJSON(object: StateEnum): string { switch (object) { case StateEnum.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case StateEnum.ON: - return 'ON'; + return "ON"; case StateEnum.OFF: - return 'OFF'; + return "OFF"; case StateEnum.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -73,7 +73,8 @@ export interface OptionalsTest_TranslationsEntry { value: string; } -export interface Child {} +export interface Child { +} function createBaseOptionalsTest(): OptionalsTest { return { @@ -82,7 +83,7 @@ function createBaseOptionalsTest(): OptionalsTest { state: 0, long: 0, truth: false, - description: '', + description: "", data: new Uint8Array(), repId: [], repChild: [], @@ -119,7 +120,7 @@ export const OptionalsTest = { if (message.truth === true) { writer.uint32(40).bool(message.truth); } - if (message.description !== undefined && message.description !== '') { + if (message.description !== undefined && message.description !== "") { writer.uint32(50).string(message.description); } if (message.data !== undefined && message.data.length !== 0) { @@ -314,7 +315,7 @@ export const OptionalsTest = { state: isSet(object.state) ? stateEnumFromJSON(object.state) : 0, long: isSet(object.long) ? Number(object.long) : 0, truth: isSet(object.truth) ? Boolean(object.truth) : false, - description: isSet(object.description) ? String(object.description) : '', + description: isSet(object.description) ? String(object.description) : "", data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(), repId: Array.isArray(object?.repId) ? object.repId.map((e: any) => Number(e)) : [], repChild: Array.isArray(object?.repChild) ? object.repChild.map((e: any) => Child.fromJSON(e)) : [], @@ -332,9 +333,9 @@ export const OptionalsTest = { optData: isSet(object.optData) ? bytesFromBase64(object.optData) : undefined, translations: isObject(object.translations) ? Object.entries(object.translations).reduce<{ [key: string]: string }>((acc, [key, value]) => { - acc[key] = String(value); - return acc; - }, {}) + acc[key] = String(value); + return acc; + }, {}) : {}, }; }, @@ -355,7 +356,7 @@ export const OptionalsTest = { obj.repId = []; } if (message.repChild) { - obj.repChild = message.repChild.map((e) => (e ? Child.toJSON(e) : undefined)); + obj.repChild = message.repChild.map((e) => e ? Child.toJSON(e) : undefined); } else { obj.repChild = []; } @@ -405,11 +406,11 @@ export const OptionalsTest = { fromPartial, I>>(object: I): OptionalsTest { const message = createBaseOptionalsTest(); message.id = object.id ?? 0; - message.child = object.child !== undefined && object.child !== null ? Child.fromPartial(object.child) : undefined; + message.child = (object.child !== undefined && object.child !== null) ? Child.fromPartial(object.child) : undefined; message.state = object.state ?? 0; message.long = object.long ?? 0; message.truth = object.truth ?? false; - message.description = object.description ?? ''; + message.description = object.description ?? ""; message.data = object.data ?? new Uint8Array(); message.repId = object.repId?.map((e) => e) || []; message.repChild = object.repChild?.map((e) => Child.fromPartial(e)) || []; @@ -419,8 +420,9 @@ export const OptionalsTest = { message.repDescription = object.repDescription?.map((e) => e) || []; message.repData = object.repData?.map((e) => e) || []; message.optId = object.optId ?? undefined; - message.optChild = - object.optChild !== undefined && object.optChild !== null ? Child.fromPartial(object.optChild) : undefined; + message.optChild = (object.optChild !== undefined && object.optChild !== null) + ? Child.fromPartial(object.optChild) + : undefined; message.optState = object.optState ?? undefined; message.optLong = object.optLong ?? undefined; message.optTruth = object.optTruth ?? undefined; @@ -433,22 +435,22 @@ export const OptionalsTest = { } return acc; }, - {} + {}, ); return message; }, }; function createBaseOptionalsTest_TranslationsEntry(): OptionalsTest_TranslationsEntry { - return { key: '', value: '' }; + return { key: "", value: "" }; } export const OptionalsTest_TranslationsEntry = { encode(message: OptionalsTest_TranslationsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } - if (message.value !== '') { + if (message.value !== "") { writer.uint32(18).string(message.value); } return writer; @@ -476,10 +478,7 @@ export const OptionalsTest_TranslationsEntry = { }, fromJSON(object: any): OptionalsTest_TranslationsEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object.value) ? String(object.value) : '', - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: OptionalsTest_TranslationsEntry): unknown { @@ -490,11 +489,11 @@ export const OptionalsTest_TranslationsEntry = { }, fromPartial, I>>( - object: I + object: I, ): OptionalsTest_TranslationsEntry { const message = createBaseOptionalsTest_TranslationsEntry(); - message.key = object.key ?? ''; - message.value = object.value ?? ''; + message.key = object.key ?? ""; + message.value = object.value ?? ""; return message; }, }; @@ -542,16 +541,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -564,36 +571,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } @@ -606,7 +607,7 @@ if (_m0.util.Long !== Long) { } function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/value/google/protobuf/struct.ts b/integration/value/google/protobuf/struct.ts index b764acb36..80a98258e 100644 --- a/integration/value/google/protobuf/struct.ts +++ b/integration/value/google/protobuf/struct.ts @@ -1,7 +1,7 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * `NullValue` is a singleton enumeration to represent the null value for the @@ -18,10 +18,10 @@ export enum NullValue { export function nullValueFromJSON(object: any): NullValue { switch (object) { case 0: - case 'NULL_VALUE': + case "NULL_VALUE": return NullValue.NULL_VALUE; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return NullValue.UNRECOGNIZED; } @@ -30,10 +30,10 @@ export function nullValueFromJSON(object: any): NullValue { export function nullValueToJSON(object: NullValue): string { switch (object) { case NullValue.NULL_VALUE: - return 'NULL_VALUE'; + return "NULL_VALUE"; case NullValue.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -67,15 +67,25 @@ export interface Struct_FieldsEntry { */ export interface Value { /** Represents a null value. */ - nullValue: NullValue | undefined; + nullValue: + | NullValue + | undefined; /** Represents a double value. */ - numberValue: number | undefined; + numberValue: + | number + | undefined; /** Represents a string value. */ - stringValue: string | undefined; + stringValue: + | string + | undefined; /** Represents a boolean value. */ - boolValue: boolean | undefined; + boolValue: + | boolean + | undefined; /** Represents a structured value. */ - structValue: { [key: string]: any } | undefined; + structValue: + | { [key: string]: any } + | undefined; /** Represents a repeated `Value`. */ listValue: Array | undefined; } @@ -129,9 +139,9 @@ export const 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; - }, {}) + acc[key] = value as any | undefined; + return acc; + }, {}) : {}, }; }, @@ -156,7 +166,7 @@ export const Struct = { } return acc; }, - {} + {}, ); return message; }, @@ -181,12 +191,12 @@ export const Struct = { }; function createBaseStruct_FieldsEntry(): Struct_FieldsEntry { - return { key: '', value: undefined }; + return { key: "", value: undefined }; } export const Struct_FieldsEntry = { encode(message: Struct_FieldsEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.key !== '') { + if (message.key !== "") { writer.uint32(10).string(message.key); } if (message.value !== undefined) { @@ -217,10 +227,7 @@ export const Struct_FieldsEntry = { }, fromJSON(object: any): Struct_FieldsEntry { - return { - key: isSet(object.key) ? String(object.key) : '', - value: isSet(object?.value) ? object.value : undefined, - }; + return { key: isSet(object.key) ? String(object.key) : "", value: isSet(object?.value) ? object.value : undefined }; }, toJSON(message: Struct_FieldsEntry): unknown { @@ -232,7 +239,7 @@ export const Struct_FieldsEntry = { fromPartial, I>>(object: I): Struct_FieldsEntry { const message = createBaseStruct_FieldsEntry(); - message.key = object.key ?? ''; + message.key = object.key ?? ""; message.value = object.value ?? undefined; return message; }, @@ -344,18 +351,18 @@ export const Value = { if (value === null) { result.nullValue = NullValue.NULL_VALUE; - } else if (typeof value === 'boolean') { + } else if (typeof value === "boolean") { result.boolValue = value; - } else if (typeof value === 'number') { + } else if (typeof value === "number") { result.numberValue = value; - } else if (typeof value === 'string') { + } else if (typeof value === "string") { result.stringValue = value; } else if (Array.isArray(value)) { result.listValue = value; - } else if (typeof value === 'object') { + } else if (typeof value === "object") { result.structValue = value; - } else if (typeof value !== 'undefined') { - throw new Error('Unsupported any value type: ' + typeof value); + } else if (typeof value !== "undefined") { + throw new Error("Unsupported any value type: " + typeof value); } return result; @@ -410,9 +417,7 @@ export const ListValue = { }, fromJSON(object: any): ListValue { - return { - values: Array.isArray(object?.values) ? [...object.values] : [], - }; + return { values: Array.isArray(object?.values) ? [...object.values] : [] }; }, toJSON(message: ListValue): unknown { @@ -446,23 +451,17 @@ export const 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/value/google/protobuf/wrappers.ts b/integration/value/google/protobuf/wrappers.ts index 5e90fd4da..3145298cb 100644 --- a/integration/value/google/protobuf/wrappers.ts +++ b/integration/value/google/protobuf/wrappers.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'google.protobuf'; +export const protobufPackage = "google.protobuf"; /** * Wrapper message for `double`. @@ -125,9 +125,7 @@ export const DoubleValue = { }, fromJSON(object: any): DoubleValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: DoubleValue): unknown { @@ -174,9 +172,7 @@ export const FloatValue = { }, fromJSON(object: any): FloatValue { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: FloatValue): unknown { @@ -223,9 +219,7 @@ export const Int64Value = { }, fromJSON(object: any): Int64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int64Value): unknown { @@ -272,9 +266,7 @@ export const UInt64Value = { }, fromJSON(object: any): UInt64Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt64Value): unknown { @@ -321,9 +313,7 @@ export const Int32Value = { }, fromJSON(object: any): Int32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: Int32Value): unknown { @@ -370,9 +360,7 @@ export const UInt32Value = { }, fromJSON(object: any): UInt32Value { - return { - value: isSet(object.value) ? Number(object.value) : 0, - }; + return { value: isSet(object.value) ? Number(object.value) : 0 }; }, toJSON(message: UInt32Value): unknown { @@ -419,9 +407,7 @@ export const BoolValue = { }, fromJSON(object: any): BoolValue { - return { - value: isSet(object.value) ? Boolean(object.value) : false, - }; + return { value: isSet(object.value) ? Boolean(object.value) : false }; }, toJSON(message: BoolValue): unknown { @@ -438,12 +424,12 @@ export const BoolValue = { }; function createBaseStringValue(): StringValue { - return { value: '' }; + return { value: "" }; } export const StringValue = { encode(message: StringValue, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.value !== '') { + if (message.value !== "") { writer.uint32(10).string(message.value); } return writer; @@ -468,9 +454,7 @@ export const StringValue = { }, fromJSON(object: any): StringValue { - return { - value: isSet(object.value) ? String(object.value) : '', - }; + return { value: isSet(object.value) ? String(object.value) : "" }; }, toJSON(message: StringValue): unknown { @@ -481,7 +465,7 @@ export const StringValue = { fromPartial, I>>(object: I): StringValue { const message = createBaseStringValue(); - message.value = object.value ?? ''; + message.value = object.value ?? ""; return message; }, }; @@ -517,9 +501,7 @@ export const BytesValue = { }, fromJSON(object: any): BytesValue { - return { - value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(), - }; + return { value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array() }; }, toJSON(message: BytesValue): unknown { @@ -540,16 +522,24 @@ 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'; + 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')); + return Uint8Array.from(globalThis.Buffer.from(b64, "base64")); } else { const bin = globalThis.atob(b64); const arr = new Uint8Array(bin.length); @@ -562,36 +552,30 @@ function bytesFromBase64(b64: string): Uint8Array { function base64FromBytes(arr: Uint8Array): string { if (globalThis.Buffer) { - return globalThis.Buffer.from(arr).toString('base64'); + return globalThis.Buffer.from(arr).toString("base64"); } else { const bin: string[] = []; arr.forEach((byte) => { bin.push(String.fromCharCode(byte)); }); - return globalThis.btoa(bin.join('')); + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/value/value.ts b/integration/value/value.ts index c3cfe1182..b89dd4536 100644 --- a/integration/value/value.ts +++ b/integration/value/value.ts @@ -1,9 +1,9 @@ /* eslint-disable */ -import * as _m0 from 'protobufjs/minimal'; -import { Value, ListValue, Struct } from './google/protobuf/struct'; -import { StringValue } from './google/protobuf/wrappers'; +import * as _m0 from "protobufjs/minimal"; +import { ListValue, Struct, Value } from "./google/protobuf/struct"; +import { StringValue } from "./google/protobuf/wrappers"; -export const protobufPackage = ''; +export const protobufPackage = ""; export interface ValueMessage { value: any | undefined; @@ -108,23 +108,17 @@ export const ValueMessage = { 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 } +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 +export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & { [K in Exclude>]: never }; function isObject(value: any): boolean { - return typeof value === 'object' && value !== null; + return typeof value === "object" && value !== null; } function isSet(value: any): boolean { diff --git a/integration/vector-tile/vector_tile.ts b/integration/vector-tile/vector_tile.ts index 572d6c420..d8b628bb4 100644 --- a/integration/vector-tile/vector_tile.ts +++ b/integration/vector-tile/vector_tile.ts @@ -1,8 +1,8 @@ /* eslint-disable */ -import * as Long from 'long'; -import * as _m0 from 'protobufjs/minimal'; +import * as Long from "long"; +import * as _m0 from "protobufjs/minimal"; -export const protobufPackage = 'vector_tile'; +export const protobufPackage = "vector_tile"; export interface Tile { layers: Tile_Layer[]; @@ -19,19 +19,19 @@ export enum Tile_GeomType { export function tile_GeomTypeFromJSON(object: any): Tile_GeomType { switch (object) { case 0: - case 'UNKNOWN': + case "UNKNOWN": return Tile_GeomType.UNKNOWN; case 1: - case 'POINT': + case "POINT": return Tile_GeomType.POINT; case 2: - case 'LINESTRING': + case "LINESTRING": return Tile_GeomType.LINESTRING; case 3: - case 'POLYGON': + case "POLYGON": return Tile_GeomType.POLYGON; case -1: - case 'UNRECOGNIZED': + case "UNRECOGNIZED": default: return Tile_GeomType.UNRECOGNIZED; } @@ -40,16 +40,16 @@ export function tile_GeomTypeFromJSON(object: any): Tile_GeomType { export function tile_GeomTypeToJSON(object: Tile_GeomType): string { switch (object) { case Tile_GeomType.UNKNOWN: - return 'UNKNOWN'; + return "UNKNOWN"; case Tile_GeomType.POINT: - return 'POINT'; + return "POINT"; case Tile_GeomType.LINESTRING: - return 'LINESTRING'; + return "LINESTRING"; case Tile_GeomType.POLYGON: - return 'POLYGON'; + return "POLYGON"; case Tile_GeomType.UNRECOGNIZED: default: - return 'UNRECOGNIZED'; + return "UNRECOGNIZED"; } } @@ -110,15 +110,13 @@ export const Tile = { }, fromJSON(object: any): Tile { - return { - layers: Array.isArray(object?.layers) ? object.layers.map((e: any) => Tile_Layer.fromJSON(e)) : [], - }; + return { layers: Array.isArray(object?.layers) ? object.layers.map((e: any) => Tile_Layer.fromJSON(e)) : [] }; }, toJSON(message: Tile): unknown { const obj: any = {}; if (message.layers) { - obj.layers = message.layers.map((e) => (e ? Tile_Layer.toJSON(e) : undefined)); + obj.layers = message.layers.map((e) => e ? Tile_Layer.toJSON(e) : undefined); } else { obj.layers = []; } @@ -133,12 +131,12 @@ export const Tile = { }; function createBaseTile_Value(): Tile_Value { - return { stringValue: '', floatValue: 0, doubleValue: 0, intValue: 0, uintValue: 0, sintValue: 0, boolValue: false }; + return { stringValue: "", floatValue: 0, doubleValue: 0, intValue: 0, uintValue: 0, sintValue: 0, boolValue: false }; } export const Tile_Value = { encode(message: Tile_Value, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { - if (message.stringValue !== '') { + if (message.stringValue !== "") { writer.uint32(10).string(message.stringValue); } if (message.floatValue !== 0) { @@ -200,7 +198,7 @@ export const Tile_Value = { fromJSON(object: any): Tile_Value { return { - stringValue: isSet(object.stringValue) ? String(object.stringValue) : '', + stringValue: isSet(object.stringValue) ? String(object.stringValue) : "", floatValue: isSet(object.floatValue) ? Number(object.floatValue) : 0, doubleValue: isSet(object.doubleValue) ? Number(object.doubleValue) : 0, intValue: isSet(object.intValue) ? Number(object.intValue) : 0, @@ -224,7 +222,7 @@ export const Tile_Value = { fromPartial, I>>(object: I): Tile_Value { const message = createBaseTile_Value(); - message.stringValue = object.stringValue ?? ''; + message.stringValue = object.stringValue ?? ""; message.floatValue = object.floatValue ?? 0; message.doubleValue = object.doubleValue ?? 0; message.intValue = object.intValue ?? 0; @@ -338,7 +336,7 @@ export const Tile_Feature = { }; function createBaseTile_Layer(): Tile_Layer { - return { version: 0, name: '', features: [], keys: [], values: [], extent: 0 }; + return { version: 0, name: "", features: [], keys: [], values: [], extent: 0 }; } export const Tile_Layer = { @@ -346,7 +344,7 @@ export const Tile_Layer = { if (message.version !== 0) { writer.uint32(120).uint32(message.version); } - if (message.name !== '') { + if (message.name !== "") { writer.uint32(10).string(message.name); } for (const v of message.features) { @@ -400,7 +398,7 @@ export const Tile_Layer = { fromJSON(object: any): Tile_Layer { return { version: isSet(object.version) ? Number(object.version) : 0, - name: isSet(object.name) ? String(object.name) : '', + name: isSet(object.name) ? String(object.name) : "", features: Array.isArray(object?.features) ? object.features.map((e: any) => Tile_Feature.fromJSON(e)) : [], keys: Array.isArray(object?.keys) ? object.keys.map((e: any) => String(e)) : [], values: Array.isArray(object?.values) ? object.values.map((e: any) => Tile_Value.fromJSON(e)) : [], @@ -413,7 +411,7 @@ export const Tile_Layer = { message.version !== undefined && (obj.version = Math.round(message.version)); message.name !== undefined && (obj.name = message.name); if (message.features) { - obj.features = message.features.map((e) => (e ? Tile_Feature.toJSON(e) : undefined)); + obj.features = message.features.map((e) => e ? Tile_Feature.toJSON(e) : undefined); } else { obj.features = []; } @@ -423,7 +421,7 @@ export const Tile_Layer = { obj.keys = []; } if (message.values) { - obj.values = message.values.map((e) => (e ? Tile_Value.toJSON(e) : undefined)); + obj.values = message.values.map((e) => e ? Tile_Value.toJSON(e) : undefined); } else { obj.values = []; } @@ -434,7 +432,7 @@ export const Tile_Layer = { fromPartial, I>>(object: I): Tile_Layer { const message = createBaseTile_Layer(); message.version = object.version ?? 0; - message.name = object.name ?? ''; + message.name = object.name ?? ""; message.features = object.features?.map((e) => Tile_Feature.fromPartial(e)) || []; message.keys = object.keys?.map((e) => e) || []; message.values = object.values?.map((e) => Tile_Value.fromPartial(e)) || []; @@ -447,33 +445,35 @@ 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'; + 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 } +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 +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'); + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } return long.toNumber(); } diff --git a/integration/watch.ts b/integration/watch.ts index b1803fdd5..19ecee826 100644 --- a/integration/watch.ts +++ b/integration/watch.ts @@ -1,48 +1,48 @@ -const chokidar = require('chokidar'); -const spawn = require('child_process').spawn; -type FsEvent = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir'; +const chokidar = require("chokidar"); +const spawn = require("child_process").spawn; +type FsEvent = "add" | "addDir" | "change" | "unlink" | "unlinkDir"; const colors = { - none: '', - reset: '\x1b[0m', - green: '\x1b[32m', - red: '\x1b[31m', - yellow: '\x1b[33m', - blue: '\x1b[34m', - magenta: '\x1b[35m', - cyan: '\x1b[36m', + none: "", + reset: "\x1b[0m", + green: "\x1b[32m", + red: "\x1b[31m", + yellow: "\x1b[33m", + blue: "\x1b[34m", + magenta: "\x1b[35m", + cyan: "\x1b[36m", }; main(); function main() { - const yarn = process.platform === 'win32' ? 'yarn.cmd' : 'yarn'; - const usePolling = process.argv.includes('--polling'); - const tests = process.argv.slice(2).filter((x) => !x.startsWith('-')); + const yarn = process.platform === "win32" ? "yarn.cmd" : "yarn"; + const usePolling = process.argv.includes("--polling"); + const tests = process.argv.slice(2).filter((x) => !x.startsWith("-")); const watchOptions = { ignoreInitial: true, usePolling }; - if (process.argv.includes('-h') || process.argv.includes('--help')) showHelp(); + if (process.argv.includes("-h") || process.argv.includes("--help")) showHelp(); showSettings(tests); - chokidar.watch('integration/*/*.proto', watchOptions).on('all', integrationHandler(yarn, 'proto2bin')); - chokidar.watch('integration/*/*.proto', watchOptions).on('all', integrationHandler(yarn, 'proto2pbjs')); - chokidar.watch('integration/*/*.bin', watchOptions).on('all', integrationHandler(yarn, 'bin2ts')); - chokidar.watch('src/**/*.ts', watchOptions).on('change', srcHandler(yarn, 'bin2ts', tests)); + chokidar.watch("integration/*/*.proto", watchOptions).on("all", integrationHandler(yarn, "proto2bin")); + chokidar.watch("integration/*/*.proto", watchOptions).on("all", integrationHandler(yarn, "proto2pbjs")); + chokidar.watch("integration/*/*.bin", watchOptions).on("all", integrationHandler(yarn, "bin2ts")); + chokidar.watch("src/**/*.ts", watchOptions).on("change", srcHandler(yarn, "bin2ts", tests)); setupKeys({ - ['']: () => yarnRun(yarn, 'bin2ts', 'enter'), - ['q']: () => process.exit(), - ['\u0003']: () => process.exit(), // ctrl-c + [""]: () => yarnRun(yarn, "bin2ts", "enter"), + ["q"]: () => process.exit(), + ["\u0003"]: () => process.exit(), // ctrl-c }); } function setupKeys(bindings: { [p: string]: () => void }) { process.stdin.setRawMode(true); process.stdin.resume(); - process.stdin.setEncoding('utf8'); + process.stdin.setEncoding("utf8"); Object.entries(bindings).forEach(([key, handler]) => { - process.stdin.on('data', (data) => { + process.stdin.on("data", (data) => { if (data.toString().trim() === key) handler(); }); }); @@ -73,21 +73,21 @@ Examples: function showSettings(tests: string[]) { console.log(`${colors.yellow}`); console.log(`Watching for changes:`); - console.log('- integration/\tRegenerating integration/*/*.proto to .bin and .ts'); + console.log("- integration/\tRegenerating integration/*/*.proto to .bin and .ts"); if (tests.length) { - console.log(`- src/\t\tRegenerating integration/{${tests.join(', ')}}/*.proto to .ts`); + console.log(`- src/\t\tRegenerating integration/{${tests.join(", ")}}/*.proto to .ts`); } - console.log('\nPress enter to regenerate all integration tests.'); - console.log('Press ctrl+c or q to exit'); + console.log("\nPress enter to regenerate all integration tests."); + console.log("Press ctrl+c or q to exit"); console.log(colors.reset); } function integrationHandler(yarn: string, task: string) { return (event: FsEvent, triggerPath: string) => { - if (event !== 'add' && event !== 'change') return; + if (event !== "add" && event !== "change") return; - triggerPath = triggerPath.replace(/\\/g, '/'); // windows - const relativePath = triggerPath.replace(/^integration\//, ''); + triggerPath = triggerPath.replace(/\\/g, "/"); // windows + const relativePath = triggerPath.replace(/^integration\//, ""); yarnRun(yarn, task, triggerPath, relativePath); }; @@ -96,29 +96,29 @@ function integrationHandler(yarn: string, task: string) { function yarnRun(yarn: string, task: string, header: string, taskArgument?: string) { const yarnArgs = taskArgument ? [task, taskArgument] : [task]; - console.log(formatLog(colors.green, header, task, `${yarn} ${yarnArgs.join(' ')}`)); + console.log(formatLog(colors.green, header, task, `${yarn} ${yarnArgs.join(" ")}`)); const yarnProcess = spawn(yarn, yarnArgs); - yarnProcess.stdout.on('data', (data: Buffer) => console.log(formatLog(colors.none, header, task, data.toString()))); - yarnProcess.stderr.on('data', (data: Buffer) => console.error(formatLog(colors.red, header, task, data.toString()))); - yarnProcess.on('error', (err: Error) => console.error(formatLog(colors.red, header, task, err.message))); - yarnProcess.on('close', (code: number) => { + yarnProcess.stdout.on("data", (data: Buffer) => console.log(formatLog(colors.none, header, task, data.toString()))); + yarnProcess.stderr.on("data", (data: Buffer) => console.error(formatLog(colors.red, header, task, data.toString()))); + yarnProcess.on("error", (err: Error) => console.error(formatLog(colors.red, header, task, err.message))); + yarnProcess.on("close", (code: number) => { if (code !== 0) { console.error(formatLog(colors.red, header, task, `Exited with code ${code}`)); } else { - console.log(formatLog(colors.green, header, task, 'Done')); + console.log(formatLog(colors.green, header, task, "Done")); } }); } function srcHandler(yarn: string, task: string, tests: string[]) { return async (triggerPath: string) => { - triggerPath = triggerPath.replace(/\\/g, '/'); + triggerPath = triggerPath.replace(/\\/g, "/"); if (tests.length === 0) { const notice = `Plugin modified! Press [enter] to regenerate all integration tests or run 'yarn watch [TEST, ...]'. See 'yarn watch --help'.`; - console.log(formatLog(colors.yellow, triggerPath, 'watch', notice)); + console.log(formatLog(colors.yellow, triggerPath, "watch", notice)); } else { - yarnRun(yarn, task, triggerPath, tests.join(' ')); + yarnRun(yarn, task, triggerPath, tests.join(" ")); } }; } @@ -126,9 +126,9 @@ function srcHandler(yarn: string, task: string, tests: string[]) { function formatLog(color: string, triggerPath: string, category: string, message: string) { return ( message - .split('\n') + .split("\n") .filter((line) => line.length) .map((line) => `${colors.reset}${triggerPath} ${colors.cyan}[${category}]${colors.reset} ${color}` + line) - .join('\n') + colors.reset + .join("\n") + colors.reset ); } diff --git a/package.json b/package.json index 946d5f279..dc6618eca 100644 --- a/package.json +++ b/package.json @@ -20,10 +20,10 @@ "proto2pbjs:local": "integration/pbjs.sh", "bin2ts:local": "integration/codegen.sh", "test": "yarn jest -c jest.config.js --maxWorkers=2", - "prettier": "prettier --write {src,tests}/**/*.ts integration/*.ts", - "prettier:check": "prettier --list-different {src,tests}/**/*.ts", + "format": "prettier --write {src,tests}/**/*.ts integration/*.ts", + "format:check": "prettier --list-different {src,tests}/**/*.ts", "setup:docker": "docker compose build", - "watch": "ts-node integration/watch.ts" + "watch": "tsx integration/watch.ts" }, "files": [ "build" @@ -58,7 +58,7 @@ "rxjs": "^7.4.0", "semantic-release": "^19.0.3", "ts-jest": "^28.0.5", - "ts-node": "^10.8.1", + "tsx": "^3.8.2", "typescript": "^4.7.4", "uglify-js": "^3.16.1" }, @@ -67,7 +67,7 @@ "dataloader": "^1.4.0", "object-hash": "^1.3.1", "protobufjs": "^6.11.3", - "ts-poet": "^4.15.0", + "ts-poet": "^5.0.1", "ts-proto-descriptors": "1.7.1" } } diff --git a/src/case.ts b/src/case.ts index 820a60350..4757aedd2 100644 --- a/src/case.ts +++ b/src/case.ts @@ -1,8 +1,8 @@ -import { Options } from './options'; +import { Options } from "./options"; /** Converts `key` to TS/JS camel-case idiom, unless overridden not to. */ -export function maybeSnakeToCamel(key: string, options: Pick): string { - if (options.snakeToCamel.includes('keys') && key.includes('_')) { +export function maybeSnakeToCamel(key: string, options: Pick): string { + if (options.snakeToCamel.includes("keys") && key.includes("_")) { return snakeToCamel(key); } else { return key; @@ -12,17 +12,17 @@ export function maybeSnakeToCamel(key: string, options: Pick { // If the word is already mixed case, leave the existing case as-is word = hasLowerCase ? word : word.toLowerCase(); return i === 0 ? word : capitalize(word); }) - .join(''); + .join(""); } export function camelToSnake(s: string): string { - return s.replace(/\w([A-Z])/g, (m) => m[0] + '_' + m[1]).toUpperCase(); + return s.replace(/\w([A-Z])/g, (m) => m[0] + "_" + m[1]).toUpperCase(); } export function capitalize(s: string): string { diff --git a/src/context.ts b/src/context.ts index 093fc1e1b..413b0594c 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1,6 +1,6 @@ -import { TypeMap } from './types'; -import { Utils } from './main'; -import { Options } from './options'; +import { TypeMap } from "./types"; +import { Utils } from "./main"; +import { Options } from "./options"; /** Provides a parameter object for passing around the various context/config data. */ export interface Context { diff --git a/src/encode.ts b/src/encode.ts index 9c81f79d4..bd5a0fe71 100644 --- a/src/encode.ts +++ b/src/encode.ts @@ -1,8 +1,8 @@ -import { Context } from './context'; -import { code, Code, Import } from 'ts-poet'; -import { messageToTypeName, wrapperTypeName } from './types'; -import { LongOption } from './options'; -import { impProto } from './utils'; +import { Context } from "./context"; +import { code, Code, Import } from "ts-poet"; +import { messageToTypeName, wrapperTypeName } from "./types"; +import { LongOption } from "./options"; +import { impProto } from "./utils"; export function generateEncoder(ctx: Context, typeName: string): Code { const name = wrapperTypeName(typeName); @@ -10,42 +10,42 @@ export function generateEncoder(ctx: Context, typeName: string): Code { return code`${messageToTypeName(ctx, typeName, { keepValueType: true })}.encode(value).finish()`; } - if (name == 'Timestamp') { - const TimestampValue = impProto(ctx.options, 'google/protobuf/timestamp', name); + if (name == "Timestamp") { + const TimestampValue = impProto(ctx.options, "google/protobuf/timestamp", name); return code`${TimestampValue}.encode(${ctx.utils.toTimestamp}(value)).finish()`; } - if (name == 'Struct') { - const StructType = impProto(ctx.options, 'google/protobuf/struct', name); + if (name == "Struct") { + const StructType = impProto(ctx.options, "google/protobuf/struct", name); return code`${StructType}.encode(${StructType}.wrap(value)).finish()`; } - if (name == 'ListValue') { - const ListValueType = impProto(ctx.options, 'google/protobuf/struct', name); + if (name == "ListValue") { + const ListValueType = impProto(ctx.options, "google/protobuf/struct", name); return code`${ListValueType}.encode({values: value ?? []}).finish()`; } - const TypeValue = impProto(ctx.options, 'google/protobuf/wrappers', name); + const TypeValue = impProto(ctx.options, "google/protobuf/wrappers", name); switch (name) { - case 'StringValue': + case "StringValue": return code`${TypeValue}.encode({value: value ?? ""}).finish()`; - case 'Int32Value': - case 'UInt32Value': - case 'DoubleValue': - case 'FloatValue': + case "Int32Value": + case "UInt32Value": + case "DoubleValue": + case "FloatValue": return code`${TypeValue}.encode({value: value ?? 0}).finish()`; - case 'Int64Value': - case 'UInt64Value': + case "Int64Value": + case "UInt64Value": if (ctx.options.forceLong === LongOption.LONG) { return code`${TypeValue}.encode({value: value ? value.toNumber(): 0}).finish()`; } return code`${TypeValue}.encode({value: value ?? 0 }).finish()`; - case 'BoolValue': + case "BoolValue": return code`${TypeValue}.encode({value: value ?? false}).finish()`; - case 'BytesValue': + case "BytesValue": return code`${TypeValue}.encode({value: value ?? new Uint8Array()}).finish()`; } @@ -61,17 +61,17 @@ export function generateDecoder(ctx: Context, typeName: string): Code { let TypeValue: Import; - if (name == 'Timestamp') { - TypeValue = impProto(ctx.options, 'google/protobuf/timestamp', name); + if (name == "Timestamp") { + TypeValue = impProto(ctx.options, "google/protobuf/timestamp", name); return code`${TypeValue}.decode(value)`; } - if (name == 'Struct' || name == 'ListValue') { - TypeValue = impProto(ctx.options, 'google/protobuf/struct', name); + if (name == "Struct" || name == "ListValue") { + TypeValue = impProto(ctx.options, "google/protobuf/struct", name); return code`${TypeValue}.unwrap(${TypeValue}.decode(value))`; } - TypeValue = impProto(ctx.options, 'google/protobuf/wrappers', name); + TypeValue = impProto(ctx.options, "google/protobuf/wrappers", name); return code`${TypeValue}.decode(value).value`; } diff --git a/src/enums.ts b/src/enums.ts index 32f996979..508c8f2ab 100644 --- a/src/enums.ts +++ b/src/enums.ts @@ -1,11 +1,11 @@ -import { code, def, Code, joinCode } from 'ts-poet'; -import { EnumDescriptorProto } from 'ts-proto-descriptors'; -import { maybeAddComment } from './utils'; -import { camelCase } from './case'; -import SourceInfo, { Fields } from './sourceInfo'; -import { Context } from './context'; - -const UNRECOGNIZED_ENUM_NAME = 'UNRECOGNIZED'; +import { code, def, Code, joinCode } from "ts-poet"; +import { EnumDescriptorProto } from "ts-proto-descriptors"; +import { maybeAddComment } from "./utils"; +import { camelCase } from "./case"; +import SourceInfo, { Fields } from "./sourceInfo"; +import { Context } from "./context"; + +const UNRECOGNIZED_ENUM_NAME = "UNRECOGNIZED"; const UNRECOGNIZED_ENUM_VALUE = -1; // Output the `enum { Foo, A = 0, B = 1 }` @@ -23,10 +23,10 @@ export function generateEnum( if (options.enumsAsLiterals) { chunks.push(code`export const ${def(fullName)} = {`); } else { - chunks.push(code`export ${options.constEnums ? 'const ' : ''}enum ${def(fullName)} {`); + chunks.push(code`export ${options.constEnums ? "const " : ""}enum ${def(fullName)} {`); } - const delimiter = options.enumsAsLiterals ? ':' : '='; + const delimiter = options.enumsAsLiterals ? ":" : "="; enumDesc.value.forEach((valueDesc, index) => { const info = sourceInfo.lookup(Fields.enum.value, index); @@ -63,7 +63,7 @@ export function generateEnum( chunks.push(generateEnumToNumber(ctx, fullName, enumDesc)); } - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } /** Generates a function with a big switch statement to decode JSON -> our enum. */ @@ -71,7 +71,7 @@ export function generateEnumFromJson(ctx: Context, fullName: string, enumDesc: E const { options, utils } = ctx; const chunks: Code[] = []; - const functionName = camelCase(fullName) + 'FromJSON'; + const functionName = camelCase(fullName) + "FromJSON"; chunks.push(code`export function ${def(functionName)}(object: any): ${fullName} {`); chunks.push(code`switch (object) {`); @@ -100,7 +100,7 @@ export function generateEnumFromJson(ctx: Context, fullName: string, enumDesc: E chunks.push(code`}`); chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } /** Generates a function with a big switch statement to encode our enum -> JSON. */ @@ -109,10 +109,10 @@ export function generateEnumToJson(ctx: Context, fullName: string, enumDesc: Enu const chunks: Code[] = []; - const functionName = camelCase(fullName) + 'ToJSON'; + const functionName = camelCase(fullName) + "ToJSON"; chunks.push( code`export function ${def(functionName)}(object: ${fullName}): ${ - ctx.options.useNumericEnumForJson ? 'number' : 'string' + ctx.options.useNumericEnumForJson ? "number" : "string" } {` ); chunks.push(code`switch (object) {`); @@ -150,7 +150,7 @@ export function generateEnumToJson(ctx: Context, fullName: string, enumDesc: Enu chunks.push(code`}`); chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } /** Generates a function with a big switch statement to encode our string enum -> int value. */ @@ -159,7 +159,7 @@ export function generateEnumToNumber(ctx: Context, fullName: string, enumDesc: E const chunks: Code[] = []; - const functionName = camelCase(fullName) + 'ToNumber'; + const functionName = camelCase(fullName) + "ToNumber"; chunks.push(code`export function ${def(functionName)}(object: ${fullName}): number {`); chunks.push(code`switch (object) {`); for (const valueDesc of enumDesc.value) { @@ -182,5 +182,5 @@ export function generateEnumToNumber(ctx: Context, fullName: string, enumDesc: E chunks.push(code`}`); chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } diff --git a/src/generate-async-iterable.ts b/src/generate-async-iterable.ts index ced7f7c7e..fe445183b 100644 --- a/src/generate-async-iterable.ts +++ b/src/generate-async-iterable.ts @@ -1,4 +1,4 @@ -import { code, Code } from 'ts-poet'; +import { code, Code } from "ts-poet"; /** Creates a function to transform a message Source to a Uint8Array Source. */ export function generateEncodeTransform(fullName: string): Code { diff --git a/src/generate-generic-service-definition.ts b/src/generate-generic-service-definition.ts index add3e6696..0ba118d1b 100644 --- a/src/generate-generic-service-definition.ts +++ b/src/generate-generic-service-definition.ts @@ -1,16 +1,16 @@ -import { Code, code, def, joinCode } from 'ts-poet'; +import { Code, code, def, joinCode } from "ts-poet"; import { FileDescriptorProto, MethodDescriptorProto, MethodOptions, MethodOptions_IdempotencyLevel, ServiceDescriptorProto, -} from 'ts-proto-descriptors'; -import { camelCase } from './case'; -import { Context } from './context'; -import SourceInfo, { Fields } from './sourceInfo'; -import { messageToTypeName } from './types'; -import { maybeAddComment, maybePrefixPackage } from './utils'; +} from "ts-proto-descriptors"; +import { camelCase } from "./case"; +import { Context } from "./context"; +import SourceInfo, { Fields } from "./sourceInfo"; +import { messageToTypeName } from "./types"; +import { maybeAddComment, maybePrefixPackage } from "./utils"; /** * Generates a framework-agnostic service descriptor. @@ -57,7 +57,7 @@ export function generateGenericServiceDefinition( } as const; `); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } function generateMethodDefinition(ctx: Context, methodDesc: MethodDescriptorProto) { @@ -91,5 +91,5 @@ function generateMethodOptions(options: MethodOptions | undefined) { chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } diff --git a/src/generate-grpc-js.ts b/src/generate-grpc-js.ts index 408d7eea0..0c262e297 100644 --- a/src/generate-grpc-js.ts +++ b/src/generate-grpc-js.ts @@ -1,28 +1,28 @@ -import { Code, code, def, imp, joinCode } from 'ts-poet'; -import { FileDescriptorProto, ServiceDescriptorProto } from 'ts-proto-descriptors'; -import { camelCase } from './case'; -import { Context } from './context'; -import SourceInfo, { Fields } from './sourceInfo'; -import { messageToTypeName, wrapperTypeName } from './types'; -import { assertInstanceOf, FormattedMethodDescriptor, maybeAddComment, maybePrefixPackage } from './utils'; -import { generateDecoder, generateEncoder } from './encode'; - -const CallOptions = imp('CallOptions@@grpc/grpc-js'); -const ChannelCredentials = imp('ChannelCredentials@@grpc/grpc-js'); -const ChannelOptions = imp('ChannelOptions@@grpc/grpc-js'); -const Client = imp('Client@@grpc/grpc-js'); -const ClientDuplexStream = imp('ClientDuplexStream@@grpc/grpc-js'); -const ClientReadableStream = imp('ClientReadableStream@@grpc/grpc-js'); -const ClientUnaryCall = imp('ClientUnaryCall@@grpc/grpc-js'); -const ClientWritableStream = imp('ClientWritableStream@@grpc/grpc-js'); -const handleBidiStreamingCall = imp('handleBidiStreamingCall@@grpc/grpc-js'); -const handleClientStreamingCall = imp('handleClientStreamingCall@@grpc/grpc-js'); -const handleServerStreamingCall = imp('handleServerStreamingCall@@grpc/grpc-js'); -const handleUnaryCall = imp('handleUnaryCall@@grpc/grpc-js'); -const UntypedServiceImplementation = imp('UntypedServiceImplementation@@grpc/grpc-js'); -const makeGenericClientConstructor = imp('makeGenericClientConstructor@@grpc/grpc-js'); -const Metadata = imp('Metadata@@grpc/grpc-js'); -const ServiceError = imp('ServiceError@@grpc/grpc-js'); +import { Code, code, def, imp, joinCode } from "ts-poet"; +import { FileDescriptorProto, ServiceDescriptorProto } from "ts-proto-descriptors"; +import { camelCase } from "./case"; +import { Context } from "./context"; +import SourceInfo, { Fields } from "./sourceInfo"; +import { messageToTypeName, wrapperTypeName } from "./types"; +import { assertInstanceOf, FormattedMethodDescriptor, maybeAddComment, maybePrefixPackage } from "./utils"; +import { generateDecoder, generateEncoder } from "./encode"; + +const CallOptions = imp("CallOptions@@grpc/grpc-js"); +const ChannelCredentials = imp("ChannelCredentials@@grpc/grpc-js"); +const ChannelOptions = imp("ChannelOptions@@grpc/grpc-js"); +const Client = imp("Client@@grpc/grpc-js"); +const ClientDuplexStream = imp("ClientDuplexStream@@grpc/grpc-js"); +const ClientReadableStream = imp("ClientReadableStream@@grpc/grpc-js"); +const ClientUnaryCall = imp("ClientUnaryCall@@grpc/grpc-js"); +const ClientWritableStream = imp("ClientWritableStream@@grpc/grpc-js"); +const handleBidiStreamingCall = imp("handleBidiStreamingCall@@grpc/grpc-js"); +const handleClientStreamingCall = imp("handleClientStreamingCall@@grpc/grpc-js"); +const handleServerStreamingCall = imp("handleServerStreamingCall@@grpc/grpc-js"); +const handleUnaryCall = imp("handleUnaryCall@@grpc/grpc-js"); +const UntypedServiceImplementation = imp("UntypedServiceImplementation@@grpc/grpc-js"); +const makeGenericClientConstructor = imp("makeGenericClientConstructor@@grpc/grpc-js"); +const Metadata = imp("Metadata@@grpc/grpc-js"); +const ServiceError = imp("ServiceError@@grpc/grpc-js"); /** * Generates a service definition and server / client stubs for the @@ -44,7 +44,7 @@ export function generateGrpcJsService( chunks.push(generateClientConstructor(fileDesc, serviceDesc)); } - return joinCode(chunks, { on: '\n\n' }); + return joinCode(chunks, { on: "\n\n" }); } function generateServiceDefinition( @@ -100,7 +100,7 @@ function generateServiceDefinition( chunks.push(code`} as const;`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } function generateServerStub(ctx: Context, sourceInfo: SourceInfo, serviceDesc: ServiceDescriptorProto) { @@ -132,7 +132,7 @@ function generateServerStub(ctx: Context, sourceInfo: SourceInfo, serviceDesc: S chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } function generateClientStub(ctx: Context, sourceInfo: SourceInfo, serviceDesc: ServiceDescriptorProto) { @@ -224,7 +224,7 @@ function generateClientStub(ctx: Context, sourceInfo: SourceInfo, serviceDesc: S chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } function generateClientConstructor(fileDesc: FileDescriptorProto, serviceDesc: ServiceDescriptorProto) { diff --git a/src/generate-grpc-web.ts b/src/generate-grpc-web.ts index f47f5fb8a..4edfd29bc 100644 --- a/src/generate-grpc-web.ts +++ b/src/generate-grpc-web.ts @@ -1,13 +1,13 @@ -import { MethodDescriptorProto, FileDescriptorProto, ServiceDescriptorProto } from 'ts-proto-descriptors'; -import { rawRequestType, requestType, responsePromiseOrObservable, responseType, observableType } from './types'; -import { Code, code, imp, joinCode } from 'ts-poet'; -import { Context } from './context'; -import { assertInstanceOf, FormattedMethodDescriptor, maybePrefixPackage } from './utils'; +import { MethodDescriptorProto, FileDescriptorProto, ServiceDescriptorProto } from "ts-proto-descriptors"; +import { rawRequestType, requestType, responsePromiseOrObservable, responseType, observableType } from "./types"; +import { Code, code, imp, joinCode } from "ts-poet"; +import { Context } from "./context"; +import { assertInstanceOf, FormattedMethodDescriptor, maybePrefixPackage } from "./utils"; -const grpc = imp('grpc@@improbable-eng/grpc-web'); -const share = imp('share@rxjs/operators'); -const take = imp('take@rxjs/operators'); -const BrowserHeaders = imp('BrowserHeaders@browser-headers'); +const grpc = imp("grpc@@improbable-eng/grpc-web"); +const share = imp("share@rxjs/operators"); +const take = imp("take@rxjs/operators"); +const BrowserHeaders = imp("BrowserHeaders@browser-headers"); /** Generates a client that uses the `@improbable-web/grpc-web` library. */ export function generateGrpcClientImpl( @@ -42,7 +42,7 @@ export function generateGrpcClientImpl( } chunks.push(code`}`); - return joinCode(chunks, { trim: false, on: '\n' }); + return joinCode(chunks, { trim: false, on: "\n" }); } /** Creates the RPC methods that client code actually calls. */ @@ -63,7 +63,7 @@ function generateRpcMethod(ctx: Context, serviceDesc: ServiceDescriptorProto, me `; } - const method = methodDesc.serverStreaming ? 'invoke' : 'unary'; + const method = methodDesc.serverStreaming ? "invoke" : "unary"; return code` ${methodDesc.formattedName}( request: ${inputType}, @@ -134,7 +134,7 @@ export function generateGrpcMethodDesc( methodName: "${methodDesc.name}", service: ${serviceDesc.name}Desc, requestStream: false, - responseStream: ${methodDesc.serverStreaming ? 'true' : 'false'}, + responseStream: ${methodDesc.serverStreaming ? "true" : "false"}, requestType: ${requestFn} as any, responseType: ${responseFn} as any, }; @@ -155,7 +155,7 @@ export function addGrpcWebMisc(ctx: Context, hasStreamingMethods: boolean): Code chunks.push(code`type UnaryMethodDefinitionish = UnaryMethodDefinitionishR;`); chunks.push(generateGrpcWebRpcType(ctx, options.returnObservable, hasStreamingMethods)); chunks.push(generateGrpcWebImpl(ctx, options.returnObservable, hasStreamingMethods)); - return joinCode(chunks, { on: '\n\n' }); + return joinCode(chunks, { on: "\n\n" }); } /** Makes an `Rpc` interface to decouple from the low-level grpc-web `grpc.invoke and grpc.unary`/etc. methods. */ @@ -164,7 +164,7 @@ function generateGrpcWebRpcType(ctx: Context, returnObservable: boolean, hasStre chunks.push(code`interface Rpc {`); - const wrapper = returnObservable ? observableType(ctx) : 'Promise'; + const wrapper = returnObservable ? observableType(ctx) : "Promise"; chunks.push(code` unary( methodDesc: T, @@ -184,7 +184,7 @@ function generateGrpcWebRpcType(ctx: Context, returnObservable: boolean, hasStre } chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } /** Implements the `Rpc` interface by making calls using the `grpc.unary` method. */ @@ -192,7 +192,7 @@ function generateGrpcWebImpl(ctx: Context, returnObservable: boolean, hasStreami const options = code` { transport?: grpc.TransportFactory, - ${hasStreamingMethods ? 'streamingTransport?: grpc.TransportFactory,' : ``} + ${hasStreamingMethods ? "streamingTransport?: grpc.TransportFactory," : ``} debug?: boolean, metadata?: grpc.Metadata, upStreamRetryCodes?: number[], diff --git a/src/generate-nestjs.ts b/src/generate-nestjs.ts index dc1efb43c..6c0915676 100644 --- a/src/generate-nestjs.ts +++ b/src/generate-nestjs.ts @@ -1,5 +1,5 @@ -import { FileDescriptorProto, ServiceDescriptorProto } from 'ts-proto-descriptors'; -import { Code, code, imp, joinCode } from 'ts-poet'; +import { FileDescriptorProto, ServiceDescriptorProto } from "ts-proto-descriptors"; +import { Code, code, imp, joinCode } from "ts-poet"; import { detectBatchMethod, isEmptyType, @@ -7,13 +7,13 @@ import { responseObservable, responsePromise, responseType, -} from './types'; -import SourceInfo, { Fields } from './sourceInfo'; -import { contextTypeVar } from './main'; -import { assertInstanceOf, FormattedMethodDescriptor, maybeAddComment, singular } from './utils'; -import { camelCase } from './case'; -import { Context } from './context'; -import { ServiceOption } from './options'; +} from "./types"; +import SourceInfo, { Fields } from "./sourceInfo"; +import { contextTypeVar } from "./main"; +import { assertInstanceOf, FormattedMethodDescriptor, maybeAddComment, singular } from "./utils"; +import { camelCase } from "./case"; +import { Context } from "./context"; +import { ServiceOption } from "./options"; export function generateNestjsServiceController( ctx: Context, @@ -24,10 +24,10 @@ export function generateNestjsServiceController( const { options } = ctx; const chunks: Code[] = []; - const Metadata = imp('Metadata@@grpc/grpc-js'); + const Metadata = imp("Metadata@@grpc/grpc-js"); maybeAddComment(sourceInfo, chunks, serviceDesc.options?.deprecated); - const t = options.context ? `<${contextTypeVar}>` : ''; + const t = options.context ? `<${contextTypeVar}>` : ""; chunks.push(code` export interface ${serviceDesc.name}Controller${t} { `); @@ -44,7 +44,7 @@ export function generateNestjsServiceController( params.push(code`request: ${requestType(ctx, methodDesc)}`); // Use metadata as last argument for interface only configuration if (options.addGrpcMetadata) { - const q = options.addNestjsRestParameter ? '' : '?'; + const q = options.addNestjsRestParameter ? "" : "?"; params.push(code`metadata${q}: ${Metadata}`); } if (options.addNestjsRestParameter) { @@ -67,13 +67,13 @@ export function generateNestjsServiceController( } chunks.push(code` - ${methodDesc.formattedName}(${joinCode(params, { on: ', ' })}): ${returns}; + ${methodDesc.formattedName}(${joinCode(params, { on: ", " })}): ${returns}; `); if (options.context) { const batchMethod = detectBatchMethod(ctx, fileDesc, serviceDesc, methodDesc); if (batchMethod) { - const maybeCtx = options.context ? 'ctx: Context,' : ''; + const maybeCtx = options.context ? "ctx: Context," : ""; chunks.push(code` ${batchMethod.singleMethodName}( ${maybeCtx} @@ -85,7 +85,7 @@ export function generateNestjsServiceController( }); chunks.push(code`}`); - return joinCode(chunks, { on: '\n\n' }); + return joinCode(chunks, { on: "\n\n" }); } export function generateNestjsServiceClient( @@ -97,7 +97,7 @@ export function generateNestjsServiceClient( const { options } = ctx; const chunks: Code[] = []; - const Metadata = imp('Metadata@@grpc/grpc-js'); + const Metadata = imp("Metadata@@grpc/grpc-js"); maybeAddComment(sourceInfo, chunks); const t = options.context ? `<${contextTypeVar}>` : ``; @@ -114,7 +114,7 @@ export function generateNestjsServiceClient( params.push(code`request: ${requestType(ctx, methodDesc)}`); // Use metadata as last argument for interface only configuration if (options.addGrpcMetadata) { - const q = options.addNestjsRestParameter ? '' : '?'; + const q = options.addNestjsRestParameter ? "" : "?"; params.push(code`metadata${q}: ${Metadata}`); } if (options.addNestjsRestParameter) { @@ -128,14 +128,14 @@ export function generateNestjsServiceClient( maybeAddComment(info, chunks, methodDesc.options?.deprecated); chunks.push(code` ${methodDesc.formattedName}( - ${joinCode(params, { on: ',' })} + ${joinCode(params, { on: "," })} ): ${returns}; `); if (options.context) { const batchMethod = detectBatchMethod(ctx, fileDesc, serviceDesc, methodDesc); if (batchMethod) { - const maybeContext = options.context ? `ctx: Context,` : ''; + const maybeContext = options.context ? `ctx: Context,` : ""; chunks.push(code` ${batchMethod.singleMethodName}( ${maybeContext} @@ -147,13 +147,13 @@ export function generateNestjsServiceClient( }); chunks.push(code`}`); - return joinCode(chunks, { on: '\n\n' }); + return joinCode(chunks, { on: "\n\n" }); } export function generateNestjsGrpcServiceMethodsDecorator(ctx: Context, serviceDesc: ServiceDescriptorProto): Code { const { options } = ctx; - const GrpcMethod = imp('GrpcMethod@@nestjs/microservices'); - const GrpcStreamMethod = imp('GrpcStreamMethod@@nestjs/microservices'); + const GrpcMethod = imp("GrpcMethod@@nestjs/microservices"); + const GrpcStreamMethod = imp("GrpcStreamMethod@@nestjs/microservices"); const grpcMethods = serviceDesc.method .filter((m) => !m.clientStreaming) @@ -174,12 +174,12 @@ export function generateNestjsGrpcServiceMethodsDecorator(ctx: Context, serviceD return code` export function ${serviceDesc.name}ControllerMethods() { return function(constructor: Function) { - const grpcMethods: string[] = [${grpcMethods.join(', ')}]; + const grpcMethods: string[] = [${grpcMethods.join(", ")}]; for (const method of grpcMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); ${GrpcMethod}('${serviceDesc.name}', method)(constructor.prototype[method], method, descriptor); } - const grpcStreamMethods: string[] = [${grpcStreamMethods.join(', ')}]; + const grpcStreamMethods: string[] = [${grpcStreamMethods.join(", ")}]; for (const method of grpcStreamMethods) { const descriptor: any = Reflect.getOwnPropertyDescriptor(constructor.prototype, method); ${GrpcStreamMethod}('${serviceDesc.name}', method)(constructor.prototype[method], method, descriptor); diff --git a/src/generate-nice-grpc.ts b/src/generate-nice-grpc.ts index 82e3d3f14..ade703030 100644 --- a/src/generate-nice-grpc.ts +++ b/src/generate-nice-grpc.ts @@ -1,13 +1,13 @@ -import { Code, code, def, imp, joinCode } from 'ts-poet'; -import { FileDescriptorProto, ServiceDescriptorProto } from 'ts-proto-descriptors'; -import { camelCase } from './case'; -import { Context } from './context'; -import SourceInfo, { Fields } from './sourceInfo'; -import { messageToTypeName } from './types'; -import { assertInstanceOf, FormattedMethodDescriptor, maybeAddComment } from './utils'; +import { Code, code, def, imp, joinCode } from "ts-poet"; +import { FileDescriptorProto, ServiceDescriptorProto } from "ts-proto-descriptors"; +import { camelCase } from "./case"; +import { Context } from "./context"; +import SourceInfo, { Fields } from "./sourceInfo"; +import { messageToTypeName } from "./types"; +import { assertInstanceOf, FormattedMethodDescriptor, maybeAddComment } from "./utils"; -const CallOptions = imp('CallOptions@nice-grpc-common'); -const CallContext = imp('CallContext@nice-grpc-common'); +const CallOptions = imp("CallOptions@nice-grpc-common"); +const CallContext = imp("CallContext@nice-grpc-common"); /** * Generates server / client stubs for `nice-grpc` library. @@ -23,7 +23,7 @@ export function generateNiceGrpcService( chunks.push(generateServerStub(ctx, sourceInfo, serviceDesc)); chunks.push(generateClientStub(ctx, sourceInfo, serviceDesc)); - return joinCode(chunks, { on: '\n\n' }); + return joinCode(chunks, { on: "\n\n" }); } function generateServerStub(ctx: Context, sourceInfo: SourceInfo, serviceDesc: ServiceDescriptorProto) { @@ -86,7 +86,7 @@ function generateServerStub(ctx: Context, sourceInfo: SourceInfo, serviceDesc: S chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } function generateClientStub(ctx: Context, sourceInfo: SourceInfo, serviceDesc: ServiceDescriptorProto) { @@ -149,5 +149,5 @@ function generateClientStub(ctx: Context, sourceInfo: SourceInfo, serviceDesc: S chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } diff --git a/src/generate-services.ts b/src/generate-services.ts index 42c2b04ea..1e5148997 100644 --- a/src/generate-services.ts +++ b/src/generate-services.ts @@ -1,5 +1,5 @@ -import { MethodDescriptorProto, FileDescriptorProto, ServiceDescriptorProto } from 'ts-proto-descriptors'; -import { Code, code, def, imp, joinCode } from 'ts-poet'; +import { MethodDescriptorProto, FileDescriptorProto, ServiceDescriptorProto } from "ts-proto-descriptors"; +import { Code, code, def, imp, joinCode } from "ts-poet"; import { BatchMethod, detectBatchMethod, @@ -8,7 +8,7 @@ import { responsePromiseOrObservable, responseType, observableType, -} from './types'; +} from "./types"; import { assertInstanceOf, FormattedMethodDescriptor, @@ -16,13 +16,13 @@ import { maybeAddComment, maybePrefixPackage, singular, -} from './utils'; -import SourceInfo, { Fields } from './sourceInfo'; -import { contextTypeVar } from './main'; -import { Context } from './context'; +} from "./utils"; +import SourceInfo, { Fields } from "./sourceInfo"; +import { contextTypeVar } from "./main"; +import { Context } from "./context"; -const hash = imp('hash*object-hash'); -const dataloader = imp('DataLoader*dataloader'); +const hash = imp("hash*object-hash"); +const dataloader = imp("DataLoader*dataloader"); /** * Generates an interface for `serviceDesc`. @@ -44,7 +44,7 @@ export function generateService( const chunks: Code[] = []; maybeAddComment(sourceInfo, chunks, serviceDesc.options?.deprecated); - const maybeTypeVar = options.context ? `<${contextTypeVar}>` : ''; + const maybeTypeVar = options.context ? `<${contextTypeVar}>` : ""; chunks.push(code`export interface ${def(serviceDesc.name)}${maybeTypeVar} {`); serviceDesc.method.forEach((methodDesc, index) => { @@ -59,17 +59,17 @@ export function generateService( // the grpc-web clients auto-`fromPartial` the input before handing off to grpc-web's // serde runtime, so it's okay to accept partial results from the client - const partialInput = options.outputClientImpl === 'grpc-web'; + const partialInput = options.outputClientImpl === "grpc-web"; const inputType = requestType(ctx, methodDesc, partialInput); params.push(code`request: ${inputType}`); // Use metadata as last argument for interface only configuration - if (options.outputClientImpl === 'grpc-web') { + if (options.outputClientImpl === "grpc-web") { // We have to use grpc.Metadata where grpc will come from @improbable-eng params.push(code`metadata?: grpc.Metadata`); } else if (options.addGrpcMetadata) { - const Metadata = imp('Metadata@@grpc/grpc-js'); - const q = options.addNestjsRestParameter ? '' : '?'; + const Metadata = imp("Metadata@@grpc/grpc-js"); + const q = options.addNestjsRestParameter ? "" : "?"; params.push(code`metadata${q}: ${Metadata}`); } else if (options.metadataType) { const Metadata = imp(options.metadataType); @@ -80,7 +80,7 @@ export function generateService( } chunks.push( - code`${methodDesc.formattedName}(${joinCode(params, { on: ',' })}): ${responsePromiseOrObservable( + code`${methodDesc.formattedName}(${joinCode(params, { on: "," })}): ${responsePromiseOrObservable( ctx, methodDesc )};` @@ -100,7 +100,7 @@ export function generateService( chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } function generateRegularRpcMethod( @@ -111,55 +111,55 @@ function generateRegularRpcMethod( ): Code { assertInstanceOf(methodDesc, FormattedMethodDescriptor); const { options, utils } = ctx; - const Reader = impFile(ctx.options, 'Reader@protobufjs/minimal'); + const Reader = impFile(ctx.options, "Reader@protobufjs/minimal"); const rawInputType = rawRequestType(ctx, methodDesc); 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 maybeCtx = options.context ? 'ctx,' : ''; + const maybeCtx = options.context ? "ctx," : ""; let encode = code`${rawInputType}.encode(request).finish()`; let decode = code`data => ${outputType}.decode(new ${Reader}(data))`; - if (options.useDate && rawOutputType.toString().includes('Timestamp')) { + 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)`; } else { - encode = code`request.pipe(${imp('map@rxjs/operators')}(request => ${encode}))`; + encode = code`request.pipe(${imp("map@rxjs/operators")}(request => ${encode}))`; } } let returnVariable: string; if (options.returnObservable || methodDesc.serverStreaming) { - returnVariable = 'result'; + returnVariable = "result"; if (options.useAsyncIterable) { decode = code`${rawOutputType}.decodeTransform(result)`; } else { - decode = code`result.pipe(${imp('map@rxjs/operators')}(${decode}))`; + decode = code`result.pipe(${imp("map@rxjs/operators")}(${decode}))`; } } else { - returnVariable = 'promise'; + returnVariable = "promise"; decode = code`promise.then(${decode})`; } let rpcMethod: string; if (methodDesc.clientStreaming && methodDesc.serverStreaming) { - rpcMethod = 'bidirectionalStreamingRequest'; + rpcMethod = "bidirectionalStreamingRequest"; } else if (methodDesc.serverStreaming) { - rpcMethod = 'serverStreamingRequest'; + rpcMethod = "serverStreamingRequest"; } else if (methodDesc.clientStreaming) { - rpcMethod = 'clientStreamingRequest'; + rpcMethod = "clientStreamingRequest"; } else { - rpcMethod = 'request'; + rpcMethod = "request"; } return code` ${methodDesc.formattedName}( - ${joinCode(params, { on: ',' })} + ${joinCode(params, { on: "," })} ): ${responsePromiseOrObservable(ctx, methodDesc)} { const data = ${encode}; const ${returnVariable} = this.rpc.${rpcMethod}( @@ -184,11 +184,11 @@ export function generateServiceClientImpl( // Define the FooServiceImpl class const { name } = serviceDesc; const i = options.context ? `${name}` : name; - const t = options.context ? `<${contextTypeVar}>` : ''; + const t = options.context ? `<${contextTypeVar}>` : ""; chunks.push(code`export class ${name}ClientImpl${t} implements ${def(i)} {`); // Create the constructor(rpc: Rpc) - const rpcType = options.context ? 'Rpc' : 'Rpc'; + const rpcType = options.context ? "Rpc" : "Rpc"; chunks.push(code`private readonly rpc: ${rpcType};`); chunks.push(code`constructor(rpc: ${rpcType}) {`); chunks.push(code`this.rpc = rpc;`); @@ -282,7 +282,7 @@ function generateCachingRpcMethod( const inputType = requestType(ctx, methodDesc); const outputType = responseType(ctx, methodDesc); const uniqueIdentifier = `${maybePrefixPackage(fileDesc, serviceDesc.name)}.${methodDesc.name}`; - const Reader = impFile(ctx.options, 'Reader@protobufjs/minimal'); + const Reader = impFile(ctx.options, "Reader@protobufjs/minimal"); const lambda = code` (requests) => { const responses = requests.map(async request => { @@ -326,8 +326,8 @@ function generateCachingRpcMethod( */ export function generateRpcType(ctx: Context, hasStreamingMethods: boolean): Code { const { options } = ctx; - const maybeContext = options.context ? '' : ''; - const maybeContextParam = options.context ? 'ctx: Context,' : ''; + const maybeContext = options.context ? "" : ""; + const maybeContextParam = options.context ? "ctx: Context," : ""; const methods = [[code`request`, code`Uint8Array`, code`Promise`]]; if (hasStreamingMethods) { const observable = observableType(ctx); @@ -351,7 +351,7 @@ export function generateRpcType(ctx: Context, hasStreamingMethods: boolean): Cod ): ${method[2]};`); }); chunks.push(code` }`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } export function generateDataLoadersType(): Code { diff --git a/src/generate-type-registry.ts b/src/generate-type-registry.ts index 5a87e8ef8..8a65d18b5 100644 --- a/src/generate-type-registry.ts +++ b/src/generate-type-registry.ts @@ -1,6 +1,6 @@ -import { code, Code, joinCode } from 'ts-poet'; -import { Context } from './context'; -import { impFile } from './utils'; +import { code, Code, joinCode } from "ts-poet"; +import { Context } from "./context"; +import { impFile } from "./utils"; export function generateTypeRegistry(ctx: Context): Code { const chunks: Code[] = []; @@ -17,7 +17,7 @@ export function generateTypeRegistry(ctx: Context): Code { chunks.push(code` ${ctx.utils.Builtin.ifUsed} ${ctx.utils.DeepPartial.ifUsed}`); - return joinCode(chunks, { on: '\n\n' }); + return joinCode(chunks, { on: "\n\n" }); } function generateMessageType(ctx: Context): Code { @@ -28,8 +28,8 @@ function generateMessageType(ctx: Context): Code { chunks.push(code`$type: Message['$type'];`); if (ctx.options.outputEncodeMethods) { - const Writer = impFile(ctx.options, 'Writer@protobufjs/minimal'); - const Reader = impFile(ctx.options, 'Reader@protobufjs/minimal'); + const Writer = impFile(ctx.options, "Writer@protobufjs/minimal"); + const Reader = impFile(ctx.options, "Reader@protobufjs/minimal"); chunks.push(code`encode(message: Message, writer?: ${Writer}): ${Writer};`); chunks.push(code`decode(input: ${Reader} | Uint8Array, length?: number): Message;`); @@ -46,5 +46,5 @@ function generateMessageType(ctx: Context): Code { chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } diff --git a/src/main.ts b/src/main.ts index 7d53e0ee2..b4abcb34d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,5 @@ -import { code, Code, conditionalOutput, def, imp, joinCode } from 'ts-poet'; -import { DescriptorProto, FieldDescriptorProto, FileDescriptorProto } from 'ts-proto-descriptors'; +import { code, Code, conditionalOutput, def, imp, joinCode } from "ts-poet"; +import { DescriptorProto, FieldDescriptorProto, FileDescriptorProto } from "ts-proto-descriptors"; import { basicLongWireType, basicTypeName, @@ -37,8 +37,8 @@ import { toReaderCall, toTypeName, valueTypeName, -} from './types'; -import SourceInfo, { Fields } from './sourceInfo'; +} from "./types"; +import SourceInfo, { Fields } from "./sourceInfo"; import { assertInstanceOf, getFieldJsonName, @@ -48,36 +48,36 @@ import { maybePrefixPackage, getPropertyAccessor, impFile, -} from './utils'; -import { camelToSnake, capitalize, maybeSnakeToCamel } from './case'; +} from "./utils"; +import { camelToSnake, capitalize, maybeSnakeToCamel } from "./case"; import { generateNestjsGrpcServiceMethodsDecorator, generateNestjsServiceClient, generateNestjsServiceController, -} from './generate-nestjs'; +} from "./generate-nestjs"; import { generateDataLoaderOptionsType, generateDataLoadersType, generateRpcType, generateService, generateServiceClientImpl, -} from './generate-services'; +} from "./generate-services"; import { addGrpcWebMisc, generateGrpcClientImpl, generateGrpcMethodDesc, generateGrpcServiceDesc, -} from './generate-grpc-web'; -import { generateEncodeTransform, generateDecodeTransform } from './generate-async-iterable'; -import { generateEnum } from './enums'; -import { visit, visitServices } from './visit'; -import { DateOption, EnvOption, LongOption, OneofOption, Options, ServiceOption } from './options'; -import { Context } from './context'; -import { generateSchema } from './schema'; -import { ConditionalOutput } from 'ts-poet/build/ConditionalOutput'; -import { generateGrpcJsService } from './generate-grpc-js'; -import { generateGenericServiceDefinition } from './generate-generic-service-definition'; -import { generateNiceGrpcService } from './generate-nice-grpc'; +} from "./generate-grpc-web"; +import { generateEncodeTransform, generateDecodeTransform } from "./generate-async-iterable"; +import { generateEnum } from "./enums"; +import { visit, visitServices } from "./visit"; +import { DateOption, EnvOption, LongOption, OneofOption, Options, ServiceOption } from "./options"; +import { Context } from "./context"; +import { generateSchema } from "./schema"; +import { ConditionalOutput } from "ts-poet/build/ConditionalOutput"; +import { generateGrpcJsService } from "./generate-grpc-js"; +import { generateGenericServiceDefinition } from "./generate-generic-service-definition"; +import { generateNiceGrpcService } from "./generate-nice-grpc"; export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [string, Code] { const { options, utils } = ctx; @@ -86,12 +86,12 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri console.warn( "ts-proto: Passing useOptionals as a boolean option is deprecated and will be removed in a future version. Please pass the string 'none' instead of false." ); - options.useOptionals = 'none'; + options.useOptionals = "none"; } else if (options.useOptionals === true) { console.warn( "ts-proto: Passing useOptionals as a boolean option is deprecated and will be removed in a future version. Please pass the string 'messages' instead of true." ); - options.useOptionals = 'messages'; + options.useOptionals = "messages"; } // Google's protofiles are organized like Java, where package == the folder the file @@ -106,7 +106,7 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri // We'll also assume that the fileDesc.name is already the `company/foo.proto` path, with // the package already implicitly in it, so we won't re-append/strip/etc. it out/back in. const suffix = `${options.fileSuffix}.ts`; - const moduleName = fileDesc.name.replace('.proto', suffix); + const moduleName = fileDesc.name.replace(".proto", suffix); const chunks: Code[] = []; // Indicate this file's source protobuf package for reflective use with google.protobuf.Any @@ -143,7 +143,7 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri // If nestJs=true export [package]_PACKAGE_NAME and [service]_SERVICE_NAME const if (options.nestJs) { - const prefix = camelToSnake(fileDesc.package.replace(/\./g, '_')); + const prefix = camelToSnake(fileDesc.package.replace(/\./g, "_")); chunks.push(code`export const ${prefix}_PACKAGE_NAME = '${fileDesc.package}';`); } @@ -180,24 +180,24 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri } const structFieldNames = { - nullValue: maybeSnakeToCamel('null_value', ctx.options), - numberValue: maybeSnakeToCamel('number_value', ctx.options), - stringValue: maybeSnakeToCamel('string_value', ctx.options), - boolValue: maybeSnakeToCamel('bool_value', ctx.options), - structValue: maybeSnakeToCamel('struct_value', ctx.options), - listValue: maybeSnakeToCamel('list_value', ctx.options), + nullValue: maybeSnakeToCamel("null_value", ctx.options), + numberValue: maybeSnakeToCamel("number_value", ctx.options), + stringValue: maybeSnakeToCamel("string_value", ctx.options), + boolValue: maybeSnakeToCamel("bool_value", ctx.options), + structValue: maybeSnakeToCamel("struct_value", ctx.options), + listValue: maybeSnakeToCamel("list_value", ctx.options), }; staticMembers.push(...generateWrap(ctx, fullTypeName, structFieldNames)); staticMembers.push(...generateUnwrap(ctx, fullTypeName, structFieldNames)); chunks.push(code` export const ${def(fullName)} = { - ${joinCode(staticMembers, { on: ',\n\n' })} + ${joinCode(staticMembers, { on: ",\n\n" })} }; `); if (options.outputTypeRegistry) { - const messageTypeRegistry = impFile(options, 'messageTypeRegistry@./typeRegistry'); + const messageTypeRegistry = impFile(options, "messageTypeRegistry@./typeRegistry"); chunks.push(code` ${messageTypeRegistry}.set(${fullName}.$type, ${fullName}); @@ -223,7 +223,7 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri chunks.push(generateNestjsGrpcServiceMethodsDecorator(ctx, serviceDesc)); let serviceConstName = `${camelToSnake(serviceDesc.name)}_NAME`; - if (!serviceDesc.name.toLowerCase().endsWith('service')) { + if (!serviceDesc.name.toLowerCase().endsWith("service")) { serviceConstName = `${camelToSnake(serviceDesc.name)}_SERVICE_NAME`; } @@ -244,7 +244,7 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri if (options.outputClientImpl === true) { chunks.push(generateServiceClientImpl(ctx, fileDesc, serviceDesc)); - } else if (options.outputClientImpl === 'grpc-web') { + } else if (options.outputClientImpl === "grpc-web") { chunks.push(generateGrpcClientImpl(ctx, fileDesc, serviceDesc)); chunks.push(generateGrpcServiceDesc(fileDesc, serviceDesc)); serviceDesc.method.forEach((method) => { @@ -273,7 +273,7 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri ) { if (options.outputClientImpl === true) { chunks.push(generateRpcType(ctx, hasStreamingMethods)); - } else if (options.outputClientImpl === 'grpc-web') { + } else if (options.outputClientImpl === "grpc-web") { chunks.push(addGrpcWebMisc(ctx, hasServerStreamingMethods)); } } @@ -307,7 +307,7 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri } } - return [moduleName, joinCode(chunks, { on: '\n\n' })]; + return [moduleName, joinCode(chunks, { on: "\n\n" })]; } export type Utils = ReturnType & @@ -338,8 +338,8 @@ export function makeUtils(options: Options): Utils { function makeLongUtils(options: Options, bytes: ReturnType) { // Regardless of which `forceLong` config option we're using, we always use // the `long` library to either represent or at least sanity-check 64-bit values - const util = impFile(options, 'util@protobufjs/minimal'); - const configure = impFile(options, 'configure@protobufjs/minimal'); + const util = impFile(options, "util@protobufjs/minimal"); + const configure = impFile(options, "configure@protobufjs/minimal"); // Before esModuleInterop, we had to use 'import * as Long from long` b/c long is // an `export =` module and exports only the Long constructor (which is callable). @@ -351,10 +351,10 @@ function makeLongUtils(options: Options, bytes: ReturnType // // I.e there is not an import for long that "just works" in both esModuleInterop and // not esModuleInterop. - const LongImp = options.esModuleInterop ? imp('Long=long') : imp('Long*long'); + const LongImp = options.esModuleInterop ? imp("Long=long") : imp("Long*long"); const disclaimer = options.esModuleInterop - ? '' + ? "" : ` // If you get a compile-error about 'Constructor and ... have no overlap', // add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'.`; @@ -363,7 +363,7 @@ function makeLongUtils(options: Options, bytes: ReturnType // `imp(Long)` but really it is that + our long initialization snippet. This means the // initialization code will only be emitted in files that actually use the Long import. const Long = conditionalOutput( - 'Long', + "Long", code` ${disclaimer} if (${util}.Long !== ${LongImp}) { @@ -375,7 +375,7 @@ function makeLongUtils(options: Options, bytes: ReturnType // TODO This is unused? const numberToLong = conditionalOutput( - 'numberToLong', + "numberToLong", code` function numberToLong(number: number) { return ${Long}.fromNumber(number); @@ -384,7 +384,7 @@ function makeLongUtils(options: Options, bytes: ReturnType ); const longToString = conditionalOutput( - 'longToString', + "longToString", code` function longToString(long: ${Long}) { return long.toString(); @@ -393,7 +393,7 @@ function makeLongUtils(options: Options, bytes: ReturnType ); const longToNumber = conditionalOutput( - 'longToNumber', + "longToNumber", code` function longToNumber(long: ${Long}): number { if (long.gt(Number.MAX_SAFE_INTEGER)) { @@ -409,7 +409,7 @@ function makeLongUtils(options: Options, bytes: ReturnType function makeByteUtils() { const globalThis = conditionalOutput( - 'globalThis', + "globalThis", code` declare var self: any | undefined; declare var window: any | undefined; @@ -425,7 +425,7 @@ function makeByteUtils() { ); const bytesFromBase64 = conditionalOutput( - 'bytesFromBase64', + "bytesFromBase64", code` function bytesFromBase64(b64: string): Uint8Array { if (${globalThis}.Buffer) { @@ -442,7 +442,7 @@ function makeByteUtils() { ` ); const base64FromBytes = conditionalOutput( - 'base64FromBytes', + "base64FromBytes", code` function base64FromBytes(arr: Uint8Array): string { if (${globalThis}.Buffer) { @@ -461,7 +461,7 @@ function makeByteUtils() { } function makeDeepPartial(options: Options, longs: ReturnType) { - let oneofCase = ''; + let oneofCase = ""; if (options.oneof === OneofOption.UNIONS) { oneofCase = ` : T extends { $case: string } @@ -469,20 +469,20 @@ function makeDeepPartial(options: Options, longs: ReturnType = T extends T ? keyof T : never; ${maybeExport} type Exact = P extends ${Builtin} @@ -495,7 +495,7 @@ function makeDeepPartial(options: Options, longs: ReturnType` : code`keyof T`; const DeepPartial = conditionalOutput( - 'DeepPartial', + "DeepPartial", code` ${maybeExport} type DeepPartial = T extends ${Builtin} ? T @@ -514,10 +514,10 @@ function makeDeepPartial(options: Options, longs: ReturnType) { - const Timestamp = impProto(options, 'google/protobuf/timestamp', 'Timestamp'); + const Timestamp = impProto(options, "google/protobuf/timestamp", "Timestamp"); - let seconds: string | Code = 'date.getTime() / 1_000'; - let toNumberCode = 't.seconds'; + let seconds: string | Code = "date.getTime() / 1_000"; + let toNumberCode = "t.seconds"; if (options.forceLong === LongOption.LONG) { - toNumberCode = 't.seconds.toNumber()'; + toNumberCode = "t.seconds.toNumber()"; seconds = code`${longs.numberToLong}(date.getTime() / 1_000)`; } else if (options.forceLong === LongOption.STRING) { - toNumberCode = 'Number(t.seconds)'; + toNumberCode = "Number(t.seconds)"; // Must discard the fractional piece here // Otherwise the fraction ends up on the seconds when parsed as a Long // (note this only occurs when the string is > 8 characters) - seconds = 'Math.trunc(date.getTime() / 1_000).toString()'; + seconds = "Math.trunc(date.getTime() / 1_000).toString()"; } - const maybeTypeField = options.outputTypeRegistry ? `$type: 'google.protobuf.Timestamp',` : ''; + const maybeTypeField = options.outputTypeRegistry ? `$type: 'google.protobuf.Timestamp',` : ""; const toTimestamp = conditionalOutput( - 'toTimestamp', + "toTimestamp", options.useDate === DateOption.STRING ? code` function toTimestamp(dateStr: string): ${Timestamp} { @@ -592,7 +592,7 @@ function makeTimestampMethods(options: Options, longs: ReturnType = { [Symbol.asyncIterator](): AsyncIterator; @@ -675,7 +675,7 @@ function makeNiceGrpcServerStreamingMethodResult() { function makeGrpcWebErrorClass() { const GrpcWebError = conditionalOutput( - 'GrpcWebError', + "GrpcWebError", code` export class GrpcWebError extends Error { constructor(message: string, public code: grpc.Code, public metadata: grpc.Metadata) { @@ -725,12 +725,12 @@ function generateInterfaceDeclaration( const name = maybeSnakeToCamel(fieldDesc.name, options); const type = toTypeName(ctx, messageDesc, fieldDesc); - const q = isOptionalProperty(fieldDesc, messageDesc.options, options) ? '?' : ''; + const q = isOptionalProperty(fieldDesc, messageDesc.options, options) ? "?" : ""; chunks.push(code`${name}${q}: ${type}, `); }); chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } function generateOneofProperty( @@ -747,7 +747,7 @@ function generateOneofProperty( let typeName = toTypeName(ctx, messageDesc, f); return code`{ $case: '${fieldName}', ${fieldName}: ${typeName} }`; }), - { on: ' | ' } + { on: " | " } ); const name = maybeSnakeToCamel(messageDesc.oneofDecl[oneofIndex].name, options); @@ -801,11 +801,11 @@ function generateBaseInstanceFactory( const name = maybeSnakeToCamel(field.name, ctx.options); const val = isWithinOneOf(field) - ? 'undefined' + ? "undefined" : isMapType(ctx, messageDesc, field) - ? '{}' + ? "{}" : isRepeated(field) - ? '[]' + ? "[]" : defaultValue(ctx, field); fields.push(code`${name}: ${val}`); @@ -817,7 +817,7 @@ function generateBaseInstanceFactory( return code` function createBase${fullName}(): ${fullName} { - return { ${joinCode(fields, { on: ',' })} }; + return { ${joinCode(fields, { on: "," })} }; } `; } @@ -832,7 +832,7 @@ function generateDecode(ctx: Context, fullName: string, messageDesc: DescriptorP createBase = code`Object.create(${createBase}) as ${fullName}`; } - const Reader = impFile(ctx.options, 'Reader@protobufjs/minimal'); + const Reader = impFile(ctx.options, "Reader@protobufjs/minimal"); // create the basic function declaration chunks.push(code` @@ -879,7 +879,7 @@ function generateDecode(ctx: Context, fullName: string, messageDesc: DescriptorP } } else if (isEnum(field)) { if (options.stringEnums) { - const fromJson = getEnumMethod(ctx, field.typeName, 'FromJSON'); + const fromJson = getEnumMethod(ctx, field.typeName, "FromJSON"); readSnippet = code`${fromJson}(${readSnippet})`; } else { readSnippet = code`${readSnippet} as any`; @@ -910,7 +910,7 @@ function generateDecode(ctx: Context, fullName: string, messageDesc: DescriptorP // and then use the snippet to handle repeated fields if necessary if (isRepeated(field)) { - const maybeNonNullAssertion = ctx.options.useOptionals === 'all' ? '!' : ''; + const maybeNonNullAssertion = ctx.options.useOptionals === "all" ? "!" : ""; if (isMapType(ctx, messageDesc, field)) { // We need a unique const within the `cast` statement @@ -966,7 +966,7 @@ function generateDecode(ctx: Context, fullName: string, messageDesc: DescriptorP chunks.push(code`return message;`); chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } /** Creates a function to encode a message by loop overing the tags. */ @@ -974,12 +974,12 @@ function generateEncode(ctx: Context, fullName: string, messageDesc: DescriptorP const { options, utils, typeMap } = ctx; const chunks: Code[] = []; - const Writer = impFile(ctx.options, 'Writer@protobufjs/minimal'); + const Writer = impFile(ctx.options, "Writer@protobufjs/minimal"); // create the basic function declaration chunks.push(code` encode( - ${messageDesc.field.length > 0 || options.unknownFields ? 'message' : '_'}: ${fullName}, + ${messageDesc.field.length > 0 || options.unknownFields ? "message" : "_"}: ${fullName}, writer: ${Writer} = ${Writer}.create(), ): ${Writer} { `); @@ -992,7 +992,7 @@ function generateEncode(ctx: Context, fullName: string, messageDesc: DescriptorP let writeSnippet: (place: string) => Code; if (isEnum(field) && options.stringEnums) { const tag = ((field.number << 3) | basicWireType(field.type)) >>> 0; - const toNumber = getEnumMethod(ctx, field.typeName, 'ToNumber'); + const toNumber = getEnumMethod(ctx, field.typeName, "ToNumber"); writeSnippet = (place) => code`writer.uint32(${tag}).${toReaderCall(field)}(${toNumber}(${place}))`; } else if (isScalar(field) || isEnum(field)) { const tag = ((field.number << 3) | basicWireType(field.type)) >>> 0; @@ -1008,7 +1008,7 @@ function generateEncode(ctx: Context, fullName: string, messageDesc: DescriptorP writeSnippet = (place) => 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 ? `$type: '${field.typeName.slice(1)}',` : ""; const type = basicTypeName(ctx, field, { keepValueType: true }); const wrappedValue = (place: string): Code => { @@ -1032,7 +1032,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 ? `$type: '${field.typeName.slice(1)}',` : ""; const entryWriteSnippet = isValueType(ctx, valueType) ? code` if (value !== undefined) { @@ -1040,7 +1040,7 @@ function generateEncode(ctx: Context, fullName: string, messageDesc: DescriptorP } ` : writeSnippet(`{ ${maybeTypeField} key: key as any, value }`); - const optionalAlternative = isOptional ? ' || {}' : ''; + const optionalAlternative = isOptional ? " || {}" : ""; chunks.push(code` Object.entries(message.${fieldName}${optionalAlternative}).forEach(([key, value]) => { ${entryWriteSnippet} @@ -1049,7 +1049,7 @@ function generateEncode(ctx: Context, fullName: string, messageDesc: DescriptorP } else if (packedType(field.type) === undefined) { const listWriteSnippet = code` for (const v of message.${fieldName}) { - ${writeSnippet('v!')}; + ${writeSnippet("v!")}; } `; if (isOptional) { @@ -1067,7 +1067,7 @@ function generateEncode(ctx: Context, fullName: string, messageDesc: DescriptorP // embedded inside of it, and we want to drop that so that we can encode it packed // (i.e. just one tag and multiple values). const tag = ((field.number << 3) | 2) >>> 0; - const toNumber = getEnumMethod(ctx, field.typeName, 'ToNumber'); + const toNumber = getEnumMethod(ctx, field.typeName, "ToNumber"); const listWriteSnippet = code` writer.uint32(${tag}).fork(); for (const v of message.${fieldName}) { @@ -1154,7 +1154,7 @@ function generateEncode(ctx: Context, fullName: string, messageDesc: DescriptorP chunks.push(code`return writer;`); chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } /** @@ -1169,7 +1169,7 @@ function generateFromJson(ctx: Context, fullName: string, fullTypeName: string, // create the basic function declaration chunks.push(code` - fromJSON(${messageDesc.field.length > 0 ? 'object' : '_'}: any): ${fullName} { + fromJSON(${messageDesc.field.length > 0 ? "object" : "_"}: any): ${fullName} { return { `); @@ -1182,7 +1182,7 @@ function generateFromJson(ctx: Context, fullName: string, fullTypeName: string, ); const canonicalFromJson: { [key: string]: { [field: string]: (from: string) => Code } } = { - ['google.protobuf.FieldMask']: { + ["google.protobuf.FieldMask"]: { paths: (from: string) => code`typeof(${from}) === 'string' ? ${from}.split(",").filter(Boolean) : Array.isArray(${from}?.paths) @@ -1195,13 +1195,13 @@ function generateFromJson(ctx: Context, fullName: string, fullTypeName: string, messageDesc.field.forEach((field) => { const fieldName = maybeSnakeToCamel(field.name, options); const jsonName = getFieldJsonName(field, options); - const jsonProperty = getPropertyAccessor('object', jsonName); - const jsonPropertyOptional = getPropertyAccessor('object', jsonName, true); + const jsonProperty = getPropertyAccessor("object", jsonName); + const jsonPropertyOptional = getPropertyAccessor("object", jsonName, true); // get code that extracts value from incoming object const readSnippet = (from: string): Code => { if (isEnum(field)) { - const fromJson = getEnumMethod(ctx, field.typeName, 'FromJSON'); + const fromJson = getEnumMethod(ctx, field.typeName, "FromJSON"); return code`${fromJson}(${from})`; } else if (isPrimitive(field)) { // Convert primitives using the String(value)/Number(value)/bytesFromBase64(value) @@ -1257,7 +1257,7 @@ function generateFromJson(ctx: Context, fullName: string, fullTypeName: string, } else if (isLong(valueField) && options.forceLong === LongOption.LONG) { return code`Long.fromValue(${from} as Long | string)`; } else if (isEnum(valueField)) { - const fromJson = getEnumMethod(ctx, valueField.typeName, 'FromJSON'); + const fromJson = getEnumMethod(ctx, valueField.typeName, "FromJSON"); return code`${fromJson}(${from})`; } else { const cstr = capitalize(valueType.toCodeString()); @@ -1290,21 +1290,21 @@ function generateFromJson(ctx: Context, fullName: string, fullTypeName: string, // and then use the snippet to handle repeated fields if necessary if (canonicalFromJson[fullTypeName]?.[fieldName]) { - chunks.push(code`${fieldName}: ${canonicalFromJson[fullTypeName][fieldName]('object')},`); + chunks.push(code`${fieldName}: ${canonicalFromJson[fullTypeName][fieldName]("object")},`); } else if (isRepeated(field)) { if (isMapType(ctx, messageDesc, field)) { const fieldType = toTypeName(ctx, messageDesc, field); - const i = maybeCastToNumber(ctx, messageDesc, field, 'key'); + const i = maybeCastToNumber(ctx, messageDesc, field, "key"); chunks.push(code` ${fieldName}: ${ctx.utils.isObject}(${jsonProperty}) ? Object.entries(${jsonProperty}).reduce<${fieldType}>((acc, [key, value]) => { - acc[${i}] = ${readSnippet('value')}; + acc[${i}] = ${readSnippet("value")}; return acc; }, {}) : {}, `); } else { - const readValueSnippet = readSnippet('e'); + const readValueSnippet = readSnippet("e"); if (readValueSnippet.toString() === code`e`.toString()) { chunks.push(code`${fieldName}: Array.isArray(${jsonPropertyOptional}) ? [...${jsonProperty}] : [],`); } else { @@ -1349,7 +1349,7 @@ function generateFromJson(ctx: Context, fullName: string, fullTypeName: string, : undefined, `); } else { - const fallback = isWithinOneOf(field) ? 'undefined' : defaultValue(ctx, field); + const fallback = isWithinOneOf(field) ? "undefined" : defaultValue(ctx, field); chunks.push(code` ${fieldName}: ${ctx.utils.isSet}(${jsonProperty}) ? ${readSnippet(`${jsonProperty}`)} @@ -1360,7 +1360,7 @@ function generateFromJson(ctx: Context, fullName: string, fullTypeName: string, // and then wrap up the switch/while/return chunks.push(code`};`); chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } function generateCanonicalToJson(fullName: string, fullProtobufTypeName: string): Code | undefined { @@ -1386,12 +1386,12 @@ function generateToJson( const canonicalToJson = generateCanonicalToJson(fullName, fullProtobufTypeName); if (canonicalToJson) { chunks.push(canonicalToJson); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } // create the basic function declaration chunks.push(code` - toJSON(${messageDesc.field.length > 0 ? 'message' : '_'}: ${fullName}): unknown { + toJSON(${messageDesc.field.length > 0 ? "message" : "_"}: ${fullName}): unknown { const obj: any = {}; `); @@ -1399,11 +1399,11 @@ function generateToJson( messageDesc.field.forEach((field) => { const fieldName = maybeSnakeToCamel(field.name, options); const jsonName = getFieldJsonName(field, options); - const jsonProperty = getPropertyAccessor('obj', jsonName); + const jsonProperty = getPropertyAccessor("obj", jsonName); const readSnippet = (from: string): Code => { if (isEnum(field)) { - const toJson = getEnumMethod(ctx, field.typeName, 'ToJSON'); + const toJson = getEnumMethod(ctx, field.typeName, "ToJSON"); return isWithinOneOf(field) ? code`${from} !== undefined ? ${toJson}(${from}) : undefined` : code`${toJson}(${from})`; @@ -1419,7 +1419,7 @@ function generateToJson( // For map types, drill-in and then admittedly re-hard-code our per-value-type logic const valueType = (typeMap.get(field.typeName)![2] as DescriptorProto).field[1]; if (isEnum(valueType)) { - const toJson = getEnumMethod(ctx, valueType.typeName, 'ToJSON'); + const toJson = getEnumMethod(ctx, valueType.typeName, "ToJSON"); return code`${toJson}(${from})`; } else if (isBytes(valueType)) { return code`${utils.base64FromBytes}(${from})`; @@ -1458,7 +1458,7 @@ function generateToJson( return code`${utils.base64FromBytes}(${from} !== undefined ? ${from} : ${defaultValue(ctx, field)})`; } } else if (isLong(field) && options.forceLong === LongOption.LONG) { - const v = isWithinOneOf(field) ? 'undefined' : defaultValue(ctx, field); + const v = isWithinOneOf(field) ? "undefined" : defaultValue(ctx, field); return code`(${from} || ${v}).toString()`; } else if (isWholeNumber(field) && !(isLong(field) && options.forceLong === LongOption.STRING)) { return code`Math.round(${from})`; @@ -1473,7 +1473,7 @@ function generateToJson( ${jsonProperty} = {}; if (message.${fieldName}) { Object.entries(message.${fieldName}).forEach(([k, v]) => { - ${jsonProperty}[k] = ${readSnippet('v')}; + ${jsonProperty}[k] = ${readSnippet("v")}; }); } `); @@ -1481,7 +1481,7 @@ function generateToJson( // Arrays might need their elements transformed chunks.push(code` if (message.${fieldName}) { - ${jsonProperty} = message.${fieldName}.map(e => ${readSnippet('e')}); + ${jsonProperty} = message.${fieldName}.map(e => ${readSnippet("e")}); } else { ${jsonProperty} = []; } @@ -1498,7 +1498,7 @@ function generateToJson( }); chunks.push(code`return obj;`); chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } function generateFromPartial(ctx: Context, fullName: string, messageDesc: DescriptorProto): Code { @@ -1506,7 +1506,7 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri const chunks: Code[] = []; // create the basic function declaration - const paramName = messageDesc.field.length > 0 ? 'object' : '_'; + const paramName = messageDesc.field.length > 0 ? "object" : "_"; if (ctx.options.useExactTypes) { chunks.push(code` @@ -1584,18 +1584,18 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri if (isRepeated(field)) { if (isMapType(ctx, messageDesc, field)) { const fieldType = toTypeName(ctx, messageDesc, field); - const i = maybeCastToNumber(ctx, messageDesc, field, 'key'); + const i = maybeCastToNumber(ctx, messageDesc, field, "key"); chunks.push(code` message.${fieldName} = Object.entries(object.${fieldName} ?? {}).reduce<${fieldType}>((acc, [key, value]) => { if (value !== undefined) { - acc[${i}] = ${readSnippet('value')}; + acc[${i}] = ${readSnippet("value")}; } return acc; }, {}); `); } else { chunks.push(code` - message.${fieldName} = object.${fieldName}?.map((e) => ${readSnippet('e')}) || []; + message.${fieldName} = object.${fieldName}?.map((e) => ${readSnippet("e")}) || []; `); } } else if (isWithinOneOfThatShouldBeUnion(options, field)) { @@ -1610,12 +1610,12 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri message.${oneofName} = { $case: '${fieldName}', ${fieldName}: ${v} }; } `); - } else if (readSnippet(`x`).toCodeString() == 'x') { + } else if (readSnippet(`x`).toCodeString() == "x") { // An optimized case of the else below that works when `readSnippet` returns the plain input - const fallback = isWithinOneOf(field) ? 'undefined' : defaultValue(ctx, field); + const fallback = isWithinOneOf(field) ? "undefined" : defaultValue(ctx, field); chunks.push(code`message.${fieldName} = object.${fieldName} ?? ${fallback};`); } else { - const fallback = isWithinOneOf(field) ? 'undefined' : defaultValue(ctx, field); + const fallback = isWithinOneOf(field) ? "undefined" : defaultValue(ctx, field); chunks.push(code` message.${fieldName} = (object.${fieldName} !== undefined && object.${fieldName} !== null) ? ${readSnippet(`object.${fieldName}`)} @@ -1627,7 +1627,7 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri // and then wrap up the switch/while/return chunks.push(code`return message;`); chunks.push(code`}`); - return joinCode(chunks, { on: '\n' }); + return joinCode(chunks, { on: "\n" }); } type StructFieldNames = { @@ -1790,7 +1790,7 @@ function generateUnwrap(ctx: Context, fullProtoTypeName: string, fieldNames: Str return chunks; } -export const contextTypeVar = 'Context extends DataLoaders'; +export const contextTypeVar = "Context extends DataLoaders"; function maybeCastToNumber( ctx: Context, @@ -1799,7 +1799,7 @@ function maybeCastToNumber( variableName: string ): string { const { keyType } = detectMapType(ctx, messageDesc, field)!; - if (keyType.toCodeString() === 'string') { + if (keyType.toCodeString() === "string") { return variableName; } else { return `Number(${variableName})`; diff --git a/src/options.ts b/src/options.ts index 549ef4f50..68e2b63b5 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,39 +1,42 @@ +import { Code } from "ts-poet"; +import { ToStringOpts } from "ts-poet/build/Code"; + export enum LongOption { - NUMBER = 'number', - LONG = 'long', - STRING = 'string', + NUMBER = "number", + LONG = "long", + STRING = "string", } export enum DateOption { - DATE = 'date', - STRING = 'string', - TIMESTAMP = 'timestamp', + DATE = "date", + STRING = "string", + TIMESTAMP = "timestamp", } export enum EnvOption { - NODE = 'node', - BROWSER = 'browser', - BOTH = 'both', + NODE = "node", + BROWSER = "browser", + BOTH = "both", } export enum OneofOption { - PROPERTIES = 'properties', - UNIONS = 'unions', + PROPERTIES = "properties", + UNIONS = "unions", } export enum ServiceOption { - GRPC = 'grpc-js', - NICE_GRPC = 'nice-grpc', - GENERIC = 'generic-definitions', - DEFAULT = 'default', - NONE = 'none', + GRPC = "grpc-js", + NICE_GRPC = "nice-grpc", + GENERIC = "generic-definitions", + DEFAULT = "default", + NONE = "none", } export type Options = { context: boolean; - snakeToCamel: Array<'json' | 'keys'>; + snakeToCamel: Array<"json" | "keys">; forceLong: LongOption; - useOptionals: boolean | 'none' | 'messages' | 'all'; // boolean is deprecated + useOptionals: boolean | "none" | "messages" | "all"; // boolean is deprecated useDate: DateOption; useMongoObjectId: boolean; oneof: OneofOption; @@ -47,7 +50,7 @@ export type Options = { stringEnums: boolean; constEnums: boolean; enumsAsLiterals: boolean; - outputClientImpl: boolean | 'grpc-web'; + outputClientImpl: boolean | "grpc-web"; outputServices: ServiceOption[]; addGrpcMetadata: boolean; metadataType: string | undefined; @@ -72,15 +75,15 @@ export type Options = { export function defaultOptions(): Options { return { context: false, - snakeToCamel: ['json', 'keys'], + snakeToCamel: ["json", "keys"], forceLong: LongOption.NUMBER, - useOptionals: 'none', + useOptionals: "none", useDate: DateOption.DATE, useMongoObjectId: false, oneof: OneofOption.PROPERTIES, esModuleInterop: false, - fileSuffix: '', - importSuffix: '', + fileSuffix: "", + importSuffix: "", lowerCaseServiceMethods: false, outputEncodeMethods: true, outputJsonMethods: true, @@ -155,7 +158,7 @@ export function optionsFromParameter(parameter: string | undefined): Options { } // Existing type-coercion inside parseParameter leaves a little to be desired. - if (typeof options.outputServices == 'string') { + if (typeof options.outputServices == "string") { options.outputServices = [options.outputServices]; } @@ -174,9 +177,9 @@ export function optionsFromParameter(parameter: string | undefined): Options { if ((options.snakeToCamel as any) === false) { options.snakeToCamel = []; } else if ((options.snakeToCamel as any) === true) { - options.snakeToCamel = ['keys', 'json']; - } else if (typeof options.snakeToCamel === 'string') { - options.snakeToCamel = (options.snakeToCamel as string).split('_') as any; + options.snakeToCamel = ["keys", "json"]; + } else if (typeof options.snakeToCamel === "string") { + options.snakeToCamel = (options.snakeToCamel as string).split("_") as any; } if (options.useJsonWireFormat) { @@ -196,9 +199,9 @@ export function optionsFromParameter(parameter: string | undefined): Options { // A very naive parse function, eventually could/should use iots/runtypes function parseParameter(parameter: string): Options { const options = {} as any; - const pairs = parameter.split(',').map((s) => s.split('=')); + const pairs = parameter.split(",").map((s) => s.split("=")); pairs.forEach(([key, _value]) => { - const value = _value === 'true' ? true : _value === 'false' ? false : _value; + const value = _value === "true" ? true : _value === "false" ? false : _value; if (options[key]) { options[key] = [options[key], value]; } else { @@ -208,7 +211,10 @@ function parseParameter(parameter: string): Options { return options; } -export function getTsPoetOpts(_options: Options): { forceModuleImport?: string[]; forceDefaultImport?: string[] } { - const imports = ['protobufjs/minimal' + _options.importSuffix]; - return _options.esModuleInterop ? { forceDefaultImport: imports } : { forceModuleImport: imports }; +export function getTsPoetOpts(_options: Options): ToStringOpts { + const imports = ["protobufjs/minimal" + _options.importSuffix]; + return { + dprintOptions: { preferSingleLine: true, lineWidth: 120 }, + ...(_options.esModuleInterop ? { forceDefaultImport: imports } : { forceModuleImport: imports }), + }; } diff --git a/src/plugin.ts b/src/plugin.ts index ff20e3617..81264bb74 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -3,14 +3,14 @@ import { CodeGeneratorResponse, CodeGeneratorResponse_Feature, FileDescriptorProto, -} from 'ts-proto-descriptors'; -import { promisify } from 'util'; -import { prefixDisableLinter, protoFilesToGenerate, readToBuffer } from './utils'; -import { generateFile, makeUtils } from './main'; -import { createTypeMap } from './types'; -import { Context } from './context'; -import { getTsPoetOpts, optionsFromParameter } from './options'; -import { generateTypeRegistry } from './generate-type-registry'; +} from "ts-proto-descriptors"; +import { promisify } from "util"; +import { prefixDisableLinter, protoFilesToGenerate, readToBuffer } from "./utils"; +import { generateFile, makeUtils } from "./main"; +import { createTypeMap } from "./types"; +import { Context } from "./context"; +import { getTsPoetOpts, optionsFromParameter } from "./options"; +import { generateTypeRegistry } from "./generate-type-registry"; // this would be the plugin called by the protoc compiler async function main() { @@ -37,7 +37,7 @@ async function main() { const utils = makeUtils(options); const ctx: Context = { options, typeMap, utils }; - const path = 'typeRegistry.ts'; + const path = "typeRegistry.ts"; const code = generateTypeRegistry(ctx); const spec = await code.toStringWithImports({ ...getTsPoetOpts(options), path }); @@ -58,7 +58,7 @@ main() process.exit(0); }) .catch((e) => { - process.stderr.write('FAILED!'); + process.stderr.write("FAILED!"); process.stderr.write(e.message); process.stderr.write(e.stack); process.exit(1); diff --git a/src/schema.ts b/src/schema.ts index 0ea26fc6e..0e6f7c49d 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -3,16 +3,16 @@ import { FileDescriptorProto, FieldDescriptorProto, FieldDescriptorProto_Type, -} from 'ts-proto-descriptors'; -import { imp, code, Code, joinCode, def } from 'ts-poet'; -import { visit, visitServices } from './visit'; -import { Context } from './context'; -import SourceInfo from './sourceInfo'; -import { impFile, maybePrefixPackage } from './utils'; -import { basicTypeName, toReaderCall } from './types'; -import { Reader } from 'protobufjs/minimal'; +} from "ts-proto-descriptors"; +import { imp, code, Code, joinCode, def } from "ts-poet"; +import { visit, visitServices } from "./visit"; +import { Context } from "./context"; +import SourceInfo from "./sourceInfo"; +import { impFile, maybePrefixPackage } from "./utils"; +import { basicTypeName, toReaderCall } from "./types"; +import { Reader } from "protobufjs/minimal"; -const fileDescriptorProto = imp('FileDescriptorProto@ts-proto-descriptors'); +const fileDescriptorProto = imp("FileDescriptorProto@ts-proto-descriptors"); const extensionCache: { [key: string]: { [key: string]: FieldDescriptorProto } } = {}; @@ -63,7 +63,7 @@ export function generateSchema(ctx: Context, fileDesc: FileDescriptorProto, sour const references: Code[] = []; function addReference(localName: string, symbol: string): void { - references.push(code`'.${maybePrefixPackage(fileDesc, localName.replace(/_/g, '.'))}': ${symbol}`); + references.push(code`'.${maybePrefixPackage(fileDesc, localName.replace(/_/g, "."))}': ${symbol}`); } visit( @@ -87,7 +87,7 @@ export function generateSchema(ctx: Context, fileDesc: FileDescriptorProto, sour }); const dependencies = fileDesc.dependency.map((dep) => { - return code`${impFile(options, `protoMetadata@./${dep.replace('.proto', '')}`)}`; + return code`${impFile(options, `protoMetadata@./${dep.replace(".proto", "")}`)}`; }); // Use toObject so that we get enums as numbers (instead of the default toJSON behavior) @@ -96,17 +96,17 @@ export function generateSchema(ctx: Context, fileDesc: FileDescriptorProto, sour // Only keep locations that include comments descriptor.sourceCodeInfo = { location: - descriptor.sourceCodeInfo?.location.filter((loc) => loc['leadingComments'] || loc['trailingComments']) || [], + descriptor.sourceCodeInfo?.location.filter((loc) => loc["leadingComments"] || loc["trailingComments"]) || [], }; let fileOptions: Code | undefined; if (fileDesc.options) { fileOptions = encodedOptionsToOptions( ctx, - '.google.protobuf.FileOptions', - (fileDesc.options as any)['_unknownFields'] + ".google.protobuf.FileOptions", + (fileDesc.options as any)["_unknownFields"] ); - delete (fileDesc.options as any)['_unknownFields']; + delete (fileDesc.options as any)["_unknownFields"]; } const messagesOptions: Code[] = []; @@ -124,10 +124,10 @@ export function generateSchema(ctx: Context, fileDesc: FileDescriptorProto, sour if (method.options) { const methodOptions = encodedOptionsToOptions( ctx, - '.google.protobuf.MethodOptions', - (method.options as any)['_unknownFields'] + ".google.protobuf.MethodOptions", + (method.options as any)["_unknownFields"] ); - delete (method.options as any)['_unknownFields']; + delete (method.options as any)["_unknownFields"]; if (methodOptions) { methodsOptions.push(code`'${method.name}': ${methodOptions}`); } @@ -138,17 +138,17 @@ export function generateSchema(ctx: Context, fileDesc: FileDescriptorProto, sour if (service.options) { serviceOptions = encodedOptionsToOptions( ctx, - '.google.protobuf.ServiceOptions', - (service.options as any)['_unknownFields'] + ".google.protobuf.ServiceOptions", + (service.options as any)["_unknownFields"] ); - delete (service.options as any)['_unknownFields']; + delete (service.options as any)["_unknownFields"]; } if (methodsOptions.length > 0 || serviceOptions) { servicesOptions.push(code` '${service.name}': { options: ${serviceOptions}, - methods: {${joinCode(methodsOptions, { on: ',' })}} + methods: {${joinCode(methodsOptions, { on: "," })}} } `); } @@ -161,10 +161,10 @@ export function generateSchema(ctx: Context, fileDesc: FileDescriptorProto, sour if (value.options) { const valueOptions = encodedOptionsToOptions( ctx, - '.google.protobuf.EnumValueOptions', - (value.options as any)['_unknownFields'] + ".google.protobuf.EnumValueOptions", + (value.options as any)["_unknownFields"] ); - delete (value.options as any)['_unknownFields']; + delete (value.options as any)["_unknownFields"]; if (valueOptions) { valuesOptions.push(code`'${value.name}': ${valueOptions}`); } @@ -175,36 +175,36 @@ export function generateSchema(ctx: Context, fileDesc: FileDescriptorProto, sour if (Enum.options) { enumOptions = encodedOptionsToOptions( ctx, - '.google.protobuf.EnumOptions', - (Enum.options as any)['_unknownFields'] + ".google.protobuf.EnumOptions", + (Enum.options as any)["_unknownFields"] ); - delete (Enum.options as any)['_unknownFields']; + delete (Enum.options as any)["_unknownFields"]; } if (valuesOptions.length > 0 || enumOptions) { enumsOptions.push(code` '${Enum.name}': { options: ${enumOptions}, - values: {${joinCode(valuesOptions, { on: ',' })}} + values: {${joinCode(valuesOptions, { on: "," })}} } `); } }); chunks.push(code` - export const ${def('protoMetadata')}: ProtoMetadata = { + export const ${def("protoMetadata")}: ProtoMetadata = { fileDescriptor: ${fileDescriptorProto}.fromPartial(${descriptor}), - references: { ${joinCode(references, { on: ',' })} }, - dependencies: [${joinCode(dependencies, { on: ',' })}], + references: { ${joinCode(references, { on: "," })} }, + dependencies: [${joinCode(dependencies, { on: "," })}], ${ fileOptions || messagesOptions.length > 0 || servicesOptions.length > 0 || enumsOptions.length > 0 ? code`options: { - ${fileOptions ? code`options: ${fileOptions},` : ''} - ${messagesOptions.length > 0 ? code`messages: {${joinCode(messagesOptions, { on: ',' })}},` : ''} - ${servicesOptions.length > 0 ? code`services: {${joinCode(servicesOptions, { on: ',' })}},` : ''} - ${enumsOptions.length > 0 ? code`enums: {${joinCode(enumsOptions, { on: ',' })}}` : ''} + ${fileOptions ? code`options: ${fileOptions},` : ""} + ${messagesOptions.length > 0 ? code`messages: {${joinCode(messagesOptions, { on: "," })}},` : ""} + ${servicesOptions.length > 0 ? code`services: {${joinCode(servicesOptions, { on: "," })}},` : ""} + ${enumsOptions.length > 0 ? code`enums: {${joinCode(enumsOptions, { on: "," })}}` : ""} }` - : '' + : "" } } `); @@ -223,12 +223,12 @@ function getExtensionValue(ctx: Context, extension: FieldDescriptorProto, data: return (reader.buf as Buffer).slice(reader.pos); }) ); - const result = resultBuffer.toString('base64'); + const result = resultBuffer.toString("base64"); return code`'${extension.name}': ${typeName}.decode(Buffer.from('${result}', 'base64'))`; } else { const reader = new Reader(data[0]); let value = (reader as any)[toReaderCall(extension)](); - if (typeof value === 'string') { + if (typeof value === "string") { value = code`"${value}"`; } return code`'${extension.name}': ${value}`; @@ -252,7 +252,7 @@ function encodedOptionsToOptions( if (resultOptions.length == 0) { return undefined; } - return code`{${joinCode(resultOptions, { on: ',' })}}`; + return code`{${joinCode(resultOptions, { on: "," })}}`; } function resolveMessageOptions(ctx: Context, message: DescriptorProto): Code | undefined { @@ -261,10 +261,10 @@ function resolveMessageOptions(ctx: Context, message: DescriptorProto): Code | u if (field.options) { const fieldOptions = encodedOptionsToOptions( ctx, - '.google.protobuf.FieldOptions', - (field.options as any)['_unknownFields'] + ".google.protobuf.FieldOptions", + (field.options as any)["_unknownFields"] ); - delete (field.options as any)['_unknownFields']; + delete (field.options as any)["_unknownFields"]; if (fieldOptions) { fieldsOptions.push(code`'${field.name}': ${fieldOptions}`); } @@ -276,10 +276,10 @@ function resolveMessageOptions(ctx: Context, message: DescriptorProto): Code | u if (oneOf.options) { const oneOfOptions = encodedOptionsToOptions( ctx, - '.google.protobuf.OneofOptions', - (oneOf.options as any)['_unknownFields'] + ".google.protobuf.OneofOptions", + (oneOf.options as any)["_unknownFields"] ); - delete (oneOf.options as any)['_unknownFields']; + delete (oneOf.options as any)["_unknownFields"]; if (oneOfOptions) { oneOfsOptions.push(code`'${oneOf.name}': ${oneOfOptions}`); } @@ -300,19 +300,19 @@ function resolveMessageOptions(ctx: Context, message: DescriptorProto): Code | u if (message.options) { messageOptions = encodedOptionsToOptions( ctx, - '.google.protobuf.MessageOptions', - (message.options as any)['_unknownFields'] + ".google.protobuf.MessageOptions", + (message.options as any)["_unknownFields"] ); - delete (message.options as any)['_unknownFields']; + delete (message.options as any)["_unknownFields"]; } if (fieldsOptions.length > 0 || oneOfsOptions.length > 0 || nestedOptions.length > 0 || messageOptions) { return code` '${message.name}': { - ${messageOptions ? code`options: ${messageOptions},` : ''} - ${fieldsOptions.length > 0 ? code`fields: {${joinCode(fieldsOptions, { on: ',' })}},` : ''} - ${oneOfsOptions.length > 0 ? code`oneof: {${joinCode(oneOfsOptions, { on: ',' })}},` : ''} - ${nestedOptions.length > 0 ? code`nested: {${joinCode(nestedOptions, { on: ',' })}},` : ''} + ${messageOptions ? code`options: ${messageOptions},` : ""} + ${fieldsOptions.length > 0 ? code`fields: {${joinCode(fieldsOptions, { on: "," })}},` : ""} + ${oneOfsOptions.length > 0 ? code`oneof: {${joinCode(oneOfsOptions, { on: "," })}},` : ""} + ${nestedOptions.length > 0 ? code`nested: {${joinCode(nestedOptions, { on: "," })}},` : ""} } `; } diff --git a/src/sourceInfo.ts b/src/sourceInfo.ts index 0141eb640..3c37e75f3 100644 --- a/src/sourceInfo.ts +++ b/src/sourceInfo.ts @@ -1,4 +1,4 @@ -import { FileDescriptorProto } from 'ts-proto-descriptors'; +import { FileDescriptorProto } from "ts-proto-descriptors"; /** This type is expecting a value from the Fields constant. */ export type FieldID = number; @@ -46,8 +46,8 @@ export interface SourceDescription { /** An empty SourceDescription for when one is not available. */ class EmptyDescription implements SourceDescription { span = []; - leadingComments = ''; - trailingComments = ''; + leadingComments = ""; + trailingComments = ""; leadingDetachedComments = []; } @@ -79,7 +79,7 @@ export default class SourceInfo implements SourceDescription { let map: SourceInfoMap = {}; if (file.sourceCodeInfo && file.sourceCodeInfo.location) { file.sourceCodeInfo.location.forEach((loc) => { - map[loc.path.join('.')] = loc; + map[loc.path.join(".")] = loc; }); } return new SourceInfo(map, new EmptyDescription()); diff --git a/src/types.ts b/src/types.ts index 77e9ceef5..c24eaee50 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,14 +9,14 @@ import { MessageOptions, MethodDescriptorProto, ServiceDescriptorProto, -} from 'ts-proto-descriptors'; -import { code, Code, imp, Import } from 'ts-poet'; -import { DateOption, EnvOption, LongOption, OneofOption, Options } from './options'; -import { visit } from './visit'; -import { fail, FormattedMethodDescriptor, impProto, maybePrefixPackage } from './utils'; -import SourceInfo from './sourceInfo'; -import { camelCase } from './case'; -import { Context } from './context'; +} from "ts-proto-descriptors"; +import { code, Code, imp, Import } from "ts-poet"; +import { DateOption, EnvOption, LongOption, OneofOption, Options } from "./options"; +import { visit } from "./visit"; +import { fail, FormattedMethodDescriptor, impProto, maybePrefixPackage } from "./utils"; +import SourceInfo from "./sourceInfo"; +import { camelCase } from "./case"; +import { Context } from "./context"; /** Based on https://github.com/dcodeIO/protobuf.js/blob/master/src/types.js#L37. */ export function basicWireType(type: FieldDescriptorProto_Type): number { @@ -46,7 +46,7 @@ export function basicWireType(type: FieldDescriptorProto_Type): number { case FieldDescriptorProto_Type.TYPE_BYTES: return 2; default: - throw new Error('Invalid type ' + type); + throw new Error("Invalid type " + type); } } @@ -109,36 +109,36 @@ export function basicTypeName( export function toReaderCall(field: FieldDescriptorProto): string { switch (field.type) { case FieldDescriptorProto_Type.TYPE_DOUBLE: - return 'double'; + return "double"; case FieldDescriptorProto_Type.TYPE_FLOAT: - return 'float'; + return "float"; case FieldDescriptorProto_Type.TYPE_INT32: case FieldDescriptorProto_Type.TYPE_ENUM: - return 'int32'; + return "int32"; case FieldDescriptorProto_Type.TYPE_UINT32: - return 'uint32'; + return "uint32"; case FieldDescriptorProto_Type.TYPE_SINT32: - return 'sint32'; + return "sint32"; case FieldDescriptorProto_Type.TYPE_FIXED32: - return 'fixed32'; + return "fixed32"; case FieldDescriptorProto_Type.TYPE_SFIXED32: - return 'sfixed32'; + return "sfixed32"; case FieldDescriptorProto_Type.TYPE_INT64: - return 'int64'; + return "int64"; case FieldDescriptorProto_Type.TYPE_UINT64: - return 'uint64'; + return "uint64"; case FieldDescriptorProto_Type.TYPE_SINT64: - return 'sint64'; + return "sint64"; case FieldDescriptorProto_Type.TYPE_FIXED64: - return 'fixed64'; + return "fixed64"; case FieldDescriptorProto_Type.TYPE_SFIXED64: - return 'sfixed64'; + return "sfixed64"; case FieldDescriptorProto_Type.TYPE_BOOL: - return 'bool'; + return "bool"; case FieldDescriptorProto_Type.TYPE_STRING: - return 'string'; + return "string"; case FieldDescriptorProto_Type.TYPE_BYTES: - return 'bytes'; + return "bytes"; default: throw new Error(`Not a primitive field ${field}`); } @@ -221,13 +221,13 @@ export function defaultValue(ctx: Context, field: FieldDescriptorProto): any { return '""'; case FieldDescriptorProto_Type.TYPE_BYTES: if (options.env === EnvOption.NODE) { - return 'Buffer.alloc(0)'; + return "Buffer.alloc(0)"; } else { - return 'new Uint8Array()'; + return "new Uint8Array()"; } case FieldDescriptorProto_Type.TYPE_MESSAGE: default: - return 'undefined'; + return "undefined"; } } @@ -240,7 +240,7 @@ export function notDefaultCheck( ): Code { const { typeMap, options } = ctx; const isOptional = isOptionalProperty(field, messageOptions, options); - const maybeNotUndefinedAnd = isOptional ? `${place} !== undefined && ` : ''; + const maybeNotUndefinedAnd = isOptional ? `${place} !== undefined && ` : ""; switch (field.type) { case FieldDescriptorProto_Type.TYPE_DOUBLE: case FieldDescriptorProto_Type.TYPE_FLOAT: @@ -282,7 +282,7 @@ export function notDefaultCheck( case FieldDescriptorProto_Type.TYPE_BYTES: return code`${maybeNotUndefinedAnd} ${place}.length !== 0`; default: - throw new Error('Not implemented for the given type.'); + throw new Error("Not implemented for the given type."); } } @@ -294,7 +294,7 @@ export function createTypeMap(request: CodeGeneratorRequest, options: Options): const typeMap: TypeMap = new Map(); for (const file of request.protoFile) { // We assume a file.name of google/protobuf/wrappers.proto --> a module path of google/protobuf/wrapper.ts - const moduleName = file.name.replace('.proto', ''); + const moduleName = file.name.replace(".proto", ""); // So given a fullName like FooMessage_InnerMessage, proto will see that as package.name.FooMessage.InnerMessage function saveMapping( tsFullName: string, @@ -303,7 +303,7 @@ export function createTypeMap(request: CodeGeneratorRequest, options: Options): protoFullName: string ): void { // package is optional, but make sure we have a dot-prefixed type name either way - const prefix = file.package.length === 0 ? '' : `.${file.package}`; + const prefix = file.package.length === 0 ? "" : `.${file.package}`; typeMap.set(`${prefix}.${protoFullName}`, [moduleName, tsFullName, desc]); } visit(file, SourceInfo.empty(), saveMapping, options, saveMapping); @@ -343,8 +343,8 @@ export function isOptionalProperty( options: Options ): boolean { const optionalMessages = - options.useOptionals === true || options.useOptionals === 'messages' || options.useOptionals === 'all'; - const optionalAll = options.useOptionals === 'all'; + options.useOptionals === true || options.useOptionals === "messages" || options.useOptionals === "all"; + const optionalAll = options.useOptionals === "all"; return ( (optionalMessages && isMessage(field) && !isRepeated(field)) || (optionalAll && !messageOptions?.mapEntry) || @@ -370,7 +370,7 @@ export function isEnum(field: FieldDescriptorProto): boolean { } export function isWithinOneOf(field: FieldDescriptorProto): boolean { - return field.hasOwnProperty('oneofIndex'); + return field.hasOwnProperty("oneofIndex"); } export function isWithinOneOfThatShouldBeUnion(options: Options, field: FieldDescriptorProto): boolean { @@ -406,11 +406,11 @@ export function isMapType(ctx: Context, messageDesc: DescriptorProto, field: Fie export function isObjectId(field: FieldDescriptorProto): boolean { // need to use endsWith instead of === because objectid could be imported from an external proto file - return field.typeName.endsWith('.ObjectId'); + return field.typeName.endsWith(".ObjectId"); } export function isTimestamp(field: FieldDescriptorProto): boolean { - return field.typeName === '.google.protobuf.Timestamp'; + return field.typeName === ".google.protobuf.Timestamp"; } export function isValueType(ctx: Context, field: FieldDescriptorProto): boolean { @@ -422,11 +422,11 @@ export function isAnyValueType(field: FieldDescriptorProto): boolean { } export function isAnyValueTypeName(typeName: string): boolean { - return typeName === 'google.protobuf.Value' || typeName === '.google.protobuf.Value'; + return typeName === "google.protobuf.Value" || typeName === ".google.protobuf.Value"; } export function isBytesValueType(field: FieldDescriptorProto): boolean { - return field.typeName === '.google.protobuf.BytesValue'; + return field.typeName === ".google.protobuf.BytesValue"; } export function isFieldMaskType(field: FieldDescriptorProto): boolean { @@ -434,7 +434,7 @@ export function isFieldMaskType(field: FieldDescriptorProto): boolean { } export function isFieldMaskTypeName(typeName: string): boolean { - return typeName === 'google.protobuf.FieldMask' || typeName === '.google.protobuf.FieldMask'; + return typeName === "google.protobuf.FieldMask" || typeName === ".google.protobuf.FieldMask"; } export function isListValueType(field: FieldDescriptorProto): boolean { @@ -442,7 +442,7 @@ export function isListValueType(field: FieldDescriptorProto): boolean { } export function isListValueTypeName(typeName: string): boolean { - return typeName === 'google.protobuf.ListValue' || typeName === '.google.protobuf.ListValue'; + return typeName === "google.protobuf.ListValue" || typeName === ".google.protobuf.ListValue"; } export function isStructType(field: FieldDescriptorProto): boolean { @@ -450,49 +450,49 @@ export function isStructType(field: FieldDescriptorProto): boolean { } export function isStructTypeName(typeName: string): boolean { - return typeName === 'google.protobuf.Struct' || typeName === '.google.protobuf.Struct'; + return typeName === "google.protobuf.Struct" || typeName === ".google.protobuf.Struct"; } export function isLongValueType(field: FieldDescriptorProto): boolean { - return field.typeName === '.google.protobuf.Int64Value' || field.typeName === '.google.protobuf.UInt64Value'; + return field.typeName === ".google.protobuf.Int64Value" || field.typeName === ".google.protobuf.UInt64Value"; } export function isEmptyType(typeName: string): boolean { - return typeName === '.google.protobuf.Empty'; + return typeName === ".google.protobuf.Empty"; } export function valueTypeName(ctx: Context, typeName: string): Code | undefined { switch (typeName) { - case '.google.protobuf.StringValue': + case ".google.protobuf.StringValue": return code`string`; - case '.google.protobuf.Int32Value': - case '.google.protobuf.UInt32Value': - case '.google.protobuf.DoubleValue': - case '.google.protobuf.FloatValue': + case ".google.protobuf.Int32Value": + case ".google.protobuf.UInt32Value": + case ".google.protobuf.DoubleValue": + case ".google.protobuf.FloatValue": return code`number`; - case '.google.protobuf.Int64Value': - case '.google.protobuf.UInt64Value': + case ".google.protobuf.Int64Value": + case ".google.protobuf.UInt64Value": // return options ? longTypeName(options) : code`number`; return longTypeName(ctx); - case '.google.protobuf.BoolValue': + case ".google.protobuf.BoolValue": return code`boolean`; - case '.google.protobuf.BytesValue': + case ".google.protobuf.BytesValue": return ctx.options.env === EnvOption.NODE ? code`Buffer` : ctx.options.useJsonWireFormat ? code`string` : code`Uint8Array`; - case '.google.protobuf.ListValue': + case ".google.protobuf.ListValue": return code`Array`; - case '.google.protobuf.Value': + case ".google.protobuf.Value": return code`any`; - case '.google.protobuf.Struct': + case ".google.protobuf.Struct": return code`{[key: string]: any}`; - case '.google.protobuf.FieldMask': + case ".google.protobuf.FieldMask": return ctx.options.useJsonWireFormat ? code`string` : code`string[]`; - case '.google.protobuf.Duration': + case ".google.protobuf.Duration": return ctx.options.useJsonWireFormat ? code`string` : undefined; - case '.google.protobuf.Timestamp': + case ".google.protobuf.Timestamp": return ctx.options.useJsonWireFormat ? code`string` : undefined; default: return undefined; @@ -501,19 +501,19 @@ export function valueTypeName(ctx: Context, typeName: string): Code | undefined export function wrapperTypeName(typeName: string): string | undefined { switch (typeName) { - case '.google.protobuf.StringValue': - case '.google.protobuf.Int32Value': - case '.google.protobuf.UInt32Value': - case '.google.protobuf.DoubleValue': - case '.google.protobuf.FloatValue': - case '.google.protobuf.Int64Value': - case '.google.protobuf.UInt64Value': - case '.google.protobuf.BoolValue': - case '.google.protobuf.BytesValue': - case '.google.protobuf.ListValue': - case '.google.protobuf.Timestamp': - case '.google.protobuf.Struct': - return typeName.split('.')[3]; + case ".google.protobuf.StringValue": + case ".google.protobuf.Int32Value": + case ".google.protobuf.UInt32Value": + case ".google.protobuf.DoubleValue": + case ".google.protobuf.FloatValue": + case ".google.protobuf.Int64Value": + case ".google.protobuf.UInt64Value": + case ".google.protobuf.BoolValue": + case ".google.protobuf.BytesValue": + case ".google.protobuf.ListValue": + case ".google.protobuf.Timestamp": + case ".google.protobuf.Struct": + return typeName.split(".")[3]; default: return undefined; } @@ -548,15 +548,15 @@ export function messageToTypeName( if ( !!typeOptions.repeated || options.useOptionals === true || - options.useOptionals === 'messages' || - options.useOptionals === 'all' + options.useOptionals === "messages" || + options.useOptionals === "all" ) { return valueType; } return code`${valueType} | undefined`; } // Look for other special prototypes like Timestamp that aren't technically wrapper types - if (!typeOptions.keepValueType && protoType === '.google.protobuf.Timestamp') { + if (!typeOptions.keepValueType && protoType === ".google.protobuf.Timestamp") { if (options.useDate == DateOption.DATE) { return code`Date`; } @@ -567,7 +567,7 @@ export function messageToTypeName( } // need to use endsWith instead of === because objectid could be imported from an external proto file - if (!typeOptions.keepValueType && options.useMongoObjectId && protoType.endsWith('.ObjectId')) { + if (!typeOptions.keepValueType && options.useMongoObjectId && protoType.endsWith(".ObjectId")) { return code`mongodb.ObjectId`; } const [module, type] = toModuleAndType(typeMap, protoType); @@ -617,7 +617,7 @@ export function toTypeName(ctx: Context, messageDesc: DescriptorProto, field: Fi if ( (!isWithinOneOf(field) && isMessage(field) && - (options.useOptionals === false || options.useOptionals === 'none')) || + (options.useOptionals === false || options.useOptionals === "none")) || (isWithinOneOf(field) && options.oneof === OneofOption.PROPERTIES) || (isWithinOneOf(field) && field.proto3Optional) ) { @@ -664,7 +664,7 @@ export function observableType(ctx: Context): Code { if (ctx.options.useAsyncIterable) { return code`AsyncIterable`; } - return code`${imp('Observable@rxjs')}`; + return code`${imp("Observable@rxjs")}`; } export function requestType(ctx: Context, methodDesc: MethodDescriptorProto, partial: boolean = false): Code { @@ -723,7 +723,7 @@ export function detectBatchMethod( methodDesc: MethodDescriptorProto ): BatchMethod | undefined { const { typeMap } = ctx; - const nameMatches = methodDesc.name.startsWith('Batch'); + const nameMatches = methodDesc.name.startsWith("Batch"); const inputType = typeMap.get(methodDesc.inputType); const outputType = typeMap.get(methodDesc.outputType); if (nameMatches && inputType && outputType) { @@ -731,7 +731,7 @@ export function detectBatchMethod( const inputTypeDesc = inputType[2] as DescriptorProto; const outputTypeDesc = outputType[2] as DescriptorProto; if (hasSingleRepeatedField(inputTypeDesc) && hasSingleRepeatedField(outputTypeDesc)) { - const singleMethodName = methodDesc.name.replace('Batch', 'Get'); + const singleMethodName = methodDesc.name.replace("Batch", "Get"); const inputFieldName = inputTypeDesc.field[0].name; const inputType = basicTypeName(ctx, inputTypeDesc.field[0]); // e.g. repeated string -> string const outputFieldName = outputTypeDesc.field[0].name; diff --git a/src/utils.ts b/src/utils.ts index ff1752068..6f22d05f2 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,15 +1,15 @@ -import { code, Code, imp, Import } from 'ts-poet'; +import { code, Code, imp, Import } from "ts-poet"; import { CodeGeneratorRequest, FieldDescriptorProto, FileDescriptorProto, MethodDescriptorProto, MethodOptions, -} from 'ts-proto-descriptors'; +} from "ts-proto-descriptors"; import ReadStream = NodeJS.ReadStream; -import { SourceDescription } from './sourceInfo'; -import { Options, ServiceOption } from './options'; -import { camelCase, snakeToCamel } from './case'; +import { SourceDescription } from "./sourceInfo"; +import { Options, ServiceOption } from "./options"; +import { camelCase, snakeToCamel } from "./case"; export function protoFilesToGenerate(request: CodeGeneratorRequest): FileDescriptorProto[] { return request.protoFile.filter((f) => request.fileToGenerate.includes(f.name)); @@ -19,14 +19,14 @@ export function readToBuffer(stream: ReadStream): Promise { return new Promise((resolve) => { const ret: Array = []; let len = 0; - stream.on('readable', () => { + stream.on("readable", () => { let chunk; while ((chunk = stream.read())) { ret.push(chunk); len += chunk.length; } }); - stream.on('end', () => { + stream.on("end", () => { resolve(Buffer.concat(ret as any, len)); }); }); @@ -53,17 +53,17 @@ const CloseComment = /\*\//g; /** Removes potentially harmful characters from comments and pushes it into chunks. */ export function maybeAddComment( - desc: Partial>, + desc: Partial>, chunks: Code[], deprecated?: boolean, - prefix: string = '' + prefix: string = "" ): void { let lines: string[] = []; if (desc.leadingComments || desc.trailingComments) { - let content = (desc.leadingComments || desc.trailingComments || '').replace(CloseComment, '* /').trim(); + let content = (desc.leadingComments || desc.trailingComments || "").replace(CloseComment, "* /").trim(); // Detect /** ... */ comments - const isDoubleStar = content.startsWith('*'); + const isDoubleStar = content.startsWith("*"); if (isDoubleStar) { content = content.substring(1).trim(); } @@ -73,21 +73,21 @@ export function maybeAddComment( content = prefix + content; } - lines = content.split('\n').map((l) => l.replace(/^ /, '').replace(/\n/, '')); + lines = content.split("\n").map((l) => l.replace(/^ /, "").replace(/\n/, "")); } // Deprecated comment should be added even if no other comment was added if (deprecated) { if (lines.length > 0) { - lines.push(''); + lines.push(""); } - lines.push('@deprecated'); + lines.push("@deprecated"); } let comment: Code; if (lines.length === 1) { comment = code`/** ${lines[0]} */`; } else { - comment = code`/**\n * ${lines.join('\n * ')}\n */`; + comment = code`/**\n * ${lines.join("\n * ")}\n */`; } if (lines.length > 0) { chunks.push(code`\n\n${comment}\n\n`); @@ -102,7 +102,7 @@ export function prefixDisableLinter(spec: string): string { } export function maybePrefixPackage(fileDesc: FileDescriptorProto, rest: string): string { - const prefix = fileDesc.package === '' ? '' : `${fileDesc.package}.`; + const prefix = fileDesc.package === "" ? "" : `${fileDesc.package}.`; return `${prefix}${rest}`; } @@ -175,12 +175,12 @@ export class FormattedMethodDescriptor implements MethodDescriptorProto { } export function getFieldJsonName( - field: Pick, - options: Pick + field: Pick, + options: Pick ): string { // jsonName will be camelCased by the protocol compiler, plus can be overridden by the user, // so just use that instead of our own maybeSnakeToCamel - if (options.snakeToCamel.includes('json')) { + if (options.snakeToCamel.includes("json")) { return field.jsonName; } else { // The user wants to keep snake case in the JSON, but we still want to see if the jsonName @@ -201,8 +201,8 @@ export function getFieldJsonName( export function getPropertyAccessor(objectName: string, propertyName: string, optional: boolean = false): string { let validIdentifier = /^[a-zA-Z_$][\w$]*$/; return validIdentifier.test(propertyName) - ? `${objectName}${optional ? '?' : ''}.${propertyName}` - : `${objectName}${optional ? '?.' : ''}[${JSON.stringify(propertyName)}]`; + ? `${objectName}${optional ? "?" : ""}.${propertyName}` + : `${objectName}${optional ? "?." : ""}[${JSON.stringify(propertyName)}]`; } export function impFile(options: Options, spec: string) { @@ -212,7 +212,7 @@ export function impFile(options: Options, spec: string) { export function impProto(options: Options, module: string, type: string): Import { const importString = `${type}@./${module}${options.fileSuffix}${options.importSuffix}`; if (options.onlyTypes) { - return imp('t:' + importString); + return imp("t:" + importString); } else { return imp(importString); } diff --git a/src/visit.ts b/src/visit.ts index 3a6a2ca76..7bcd96648 100644 --- a/src/visit.ts +++ b/src/visit.ts @@ -3,10 +3,10 @@ import { EnumDescriptorProto, FileDescriptorProto, ServiceDescriptorProto, -} from 'ts-proto-descriptors'; -import SourceInfo, { Fields } from './sourceInfo'; -import { Options } from './options'; -import { maybeSnakeToCamel } from './case'; +} from "ts-proto-descriptors"; +import SourceInfo, { Fields } from "./sourceInfo"; +import { Options } from "./options"; +import { maybeSnakeToCamel } from "./case"; type MessageVisitor = ( fullName: string, @@ -28,10 +28,10 @@ export function visit( messageFn: MessageVisitor, options: Options, enumFn: EnumVisitor = () => {}, - tsPrefix: string = '', - protoPrefix: string = '' + tsPrefix: string = "", + protoPrefix: string = "" ): void { - const isRootFile = 'syntax' in proto; + const isRootFile = "syntax" in proto; const childEnumType = isRootFile ? Fields.file.enum_type : Fields.message.enum_type; proto.enumType.forEach((enumDesc, index) => { @@ -43,7 +43,7 @@ export function visit( enumFn(tsFullName, enumDesc, nestedSourceInfo, protoFullName); }); - const messages = 'messageType' in proto ? proto.messageType : proto.nestedType; + const messages = "messageType" in proto ? proto.messageType : proto.nestedType; const childType = isRootFile ? Fields.file.message_type : Fields.message.nested_type; messages.forEach((message, index) => { @@ -53,11 +53,11 @@ export function visit( const tsFullName = tsPrefix + maybeSnakeToCamel(messageName(message), options); const nestedSourceInfo = sourceInfo.open(childType, index); messageFn(tsFullName, message, nestedSourceInfo, protoFullName); - visit(message, nestedSourceInfo, messageFn, options, enumFn, tsFullName + '_', protoFullName + '.'); + visit(message, nestedSourceInfo, messageFn, options, enumFn, tsFullName + "_", protoFullName + "."); }); } -const builtInNames = ['Date']; +const builtInNames = ["Date"]; /** Potentially suffixes `Message` to names to avoid conflicts, i.e. with `Date`. */ function messageName(message: DescriptorProto): string { diff --git a/tests/case-test.ts b/tests/case-test.ts index aa2bda572..07303072c 100644 --- a/tests/case-test.ts +++ b/tests/case-test.ts @@ -1,59 +1,59 @@ -import { maybeSnakeToCamel } from '../src/case'; -import { Options, optionsFromParameter } from '../src/options'; -import { getFieldJsonName } from '../src/utils'; +import { maybeSnakeToCamel } from "../src/case"; +import { Options, optionsFromParameter } from "../src/options"; +import { getFieldJsonName } from "../src/utils"; -const keys = optionsFromParameter('snakeToCamel=keys'); +const keys = optionsFromParameter("snakeToCamel=keys"); -describe('case', () => { - it('converts snake to camel by default', () => { - expect(maybeSnakeToCamel('foo_bar', optionsFromParameter(undefined))).toEqual('fooBar'); +describe("case", () => { + it("converts snake to camel by default", () => { + expect(maybeSnakeToCamel("foo_bar", optionsFromParameter(undefined))).toEqual("fooBar"); }); - it('leaves as-is if snakeToCamel is false', () => { - expect(maybeSnakeToCamel('foo_bar', optionsFromParameter('snakeToCamel=false'))).toEqual('foo_bar'); + it("leaves as-is if snakeToCamel is false", () => { + expect(maybeSnakeToCamel("foo_bar", optionsFromParameter("snakeToCamel=false"))).toEqual("foo_bar"); }); - it('de-upper cases', () => { - expect(maybeSnakeToCamel('FOO_BAR', keys)).toEqual('fooBar'); + it("de-upper cases", () => { + expect(maybeSnakeToCamel("FOO_BAR", keys)).toEqual("fooBar"); }); - it('leaves existing mixed cases', () => { - expect(maybeSnakeToCamel('clientI_d', keys)).toEqual('clientID'); - expect(maybeSnakeToCamel('menu_calendarI_d', keys)).toEqual('menuCalendarID'); - expect(maybeSnakeToCamel('display_nameI18n', keys)).toEqual('displayNameI18n'); + it("leaves existing mixed cases", () => { + expect(maybeSnakeToCamel("clientI_d", keys)).toEqual("clientID"); + expect(maybeSnakeToCamel("menu_calendarI_d", keys)).toEqual("menuCalendarID"); + expect(maybeSnakeToCamel("display_nameI18n", keys)).toEqual("displayNameI18n"); }); - it('leaves the first character as it was', () => { - expect(maybeSnakeToCamel('Foo_Bar', keys)).toEqual('FooBar'); + it("leaves the first character as it was", () => { + expect(maybeSnakeToCamel("Foo_Bar", keys)).toEqual("FooBar"); }); - it('does nothing is already camel', () => { - expect(maybeSnakeToCamel('FooBar', keys)).toEqual('FooBar'); + it("does nothing is already camel", () => { + expect(maybeSnakeToCamel("FooBar", keys)).toEqual("FooBar"); }); // deal with original protoc which converts // _uuid -> Uuid // __uuid -> Uuid // _uuid_foo -> UuidFoo - it('converts snake to camel with first underscore', () => { - expect(maybeSnakeToCamel('_uuid', { snakeToCamel: ['keys'] })).toEqual('Uuid'); + it("converts snake to camel with first underscore", () => { + expect(maybeSnakeToCamel("_uuid", { snakeToCamel: ["keys"] })).toEqual("Uuid"); }); - it('converts snake to camel with first double underscore', () => { - expect(maybeSnakeToCamel('__uuid', { snakeToCamel: ['keys'] })).toEqual('Uuid'); + it("converts snake to camel with first double underscore", () => { + expect(maybeSnakeToCamel("__uuid", { snakeToCamel: ["keys"] })).toEqual("Uuid"); }); - it('converts snake to camel with first underscore and camelize other', () => { - expect(maybeSnakeToCamel('_uuid_foo', { snakeToCamel: ['keys'] })).toEqual('UuidFoo'); + it("converts snake to camel with first underscore and camelize other", () => { + expect(maybeSnakeToCamel("_uuid_foo", { snakeToCamel: ["keys"] })).toEqual("UuidFoo"); }); - describe('getFieldJsonName', () => { - it('keeps snake case when jsonName is probably not set', () => { - expect(getFieldJsonName({ name: 'foo_bar', jsonName: 'fooBar' }, { snakeToCamel: [] })).toBe('foo_bar'); + describe("getFieldJsonName", () => { + it("keeps snake case when jsonName is probably not set", () => { + expect(getFieldJsonName({ name: "foo_bar", jsonName: "fooBar" }, { snakeToCamel: [] })).toBe("foo_bar"); }); - it('uses jsonName when it is set', () => { - expect(getFieldJsonName({ name: 'foo_bar', jsonName: 'foo' }, { snakeToCamel: [] })).toBe('foo'); + it("uses jsonName when it is set", () => { + expect(getFieldJsonName({ name: "foo_bar", jsonName: "foo" }, { snakeToCamel: [] })).toBe("foo"); }); }); }); diff --git a/tests/options-test.ts b/tests/options-test.ts index ccbbc6b55..7de556ee6 100644 --- a/tests/options-test.ts +++ b/tests/options-test.ts @@ -1,8 +1,8 @@ -import { DateOption, optionsFromParameter, ServiceOption } from '../src/options'; +import { DateOption, optionsFromParameter, ServiceOption } from "../src/options"; -describe('options', () => { - it('can set outputJsonMethods with nestJs=true', () => { - expect(optionsFromParameter('nestJs=true,outputJsonMethods=true')).toMatchInlineSnapshot(` +describe("options", () => { + it("can set outputJsonMethods with nestJs=true", () => { + expect(optionsFromParameter("nestJs=true,outputJsonMethods=true")).toMatchInlineSnapshot(` Object { "addGrpcMetadata": false, "addNestjsRestParameter": false, @@ -50,73 +50,73 @@ describe('options', () => { `); }); - it('can set outputJsonMethods with nestJs=true', () => { - const options = optionsFromParameter('outputClientImpl=grpc-web,addGrpcMetadata=false'); + it("can set outputJsonMethods with nestJs=true", () => { + const options = optionsFromParameter("outputClientImpl=grpc-web,addGrpcMetadata=false"); expect(options).toMatchObject({ - outputClientImpl: 'grpc-web', + outputClientImpl: "grpc-web", addGrpcMetadata: false, }); }); - it('can set fileSuffix', () => { - const options = optionsFromParameter('fileSuffix=.pb'); + it("can set fileSuffix", () => { + const options = optionsFromParameter("fileSuffix=.pb"); expect(options).toMatchObject({ - fileSuffix: '.pb', + fileSuffix: ".pb", }); }); - it('can set outputServices to false', () => { - const options = optionsFromParameter('outputServices=false'); + it("can set outputServices to false", () => { + const options = optionsFromParameter("outputServices=false"); expect(options).toMatchObject({ outputServices: [ServiceOption.NONE], }); }); - it('can set outputServices to grpc', () => { - const options = optionsFromParameter('outputServices=grpc-js'); + it("can set outputServices to grpc", () => { + const options = optionsFromParameter("outputServices=grpc-js"); expect(options).toMatchObject({ outputServices: [ServiceOption.GRPC], }); }); - it('can set useOptionals to boolean', () => { - const options = optionsFromParameter('useOptionals=true'); + it("can set useOptionals to boolean", () => { + const options = optionsFromParameter("useOptionals=true"); expect(options).toMatchObject({ useOptionals: true, }); }); - it('can set useOptionals to string', () => { - const options = optionsFromParameter('useOptionals=messages'); + it("can set useOptionals to string", () => { + const options = optionsFromParameter("useOptionals=messages"); expect(options).toMatchObject({ - useOptionals: 'messages', + useOptionals: "messages", }); }); - it('can set snakeToCamel as string', () => { - const options = optionsFromParameter('snakeToCamel=keys'); - expect(options).toMatchObject({ snakeToCamel: ['keys'] }); + it("can set snakeToCamel as string", () => { + const options = optionsFromParameter("snakeToCamel=keys"); + expect(options).toMatchObject({ snakeToCamel: ["keys"] }); }); - it('can set snakeToCamel as two values', () => { - const options = optionsFromParameter('snakeToCamel=keys_json'); - expect(options).toMatchObject({ snakeToCamel: ['keys', 'json'] }); + it("can set snakeToCamel as two values", () => { + const options = optionsFromParameter("snakeToCamel=keys_json"); + expect(options).toMatchObject({ snakeToCamel: ["keys", "json"] }); }); - it('can set multiple values as an array', () => { - const options = optionsFromParameter('foo=one,foo=two'); - expect(options).toMatchObject({ foo: ['one', 'two'] }); + it("can set multiple values as an array", () => { + const options = optionsFromParameter("foo=one,foo=two"); + expect(options).toMatchObject({ foo: ["one", "two"] }); }); - it('´output*=false implies onlyTypes', () => { - const options = optionsFromParameter('outputJsonMethods=false,outputEncodeMethods=false,outputClientImpl=false'); + it("´output*=false implies onlyTypes", () => { + const options = optionsFromParameter("outputJsonMethods=false,outputEncodeMethods=false,outputClientImpl=false"); expect(options).toMatchObject({ onlyTypes: true, }); }); - it('onlyTypes implies output*=false', () => { - const options = optionsFromParameter('onlyTypes=true'); + it("onlyTypes implies output*=false", () => { + const options = optionsFromParameter("onlyTypes=true"); expect(options).toMatchObject({ outputJsonMethods: false, outputEncodeMethods: false, @@ -125,15 +125,15 @@ describe('options', () => { }); }); - it('useJsonWireFormat requires onlyTypes', () => { - const options = optionsFromParameter('useJsonWireFormat=true'); + it("useJsonWireFormat requires onlyTypes", () => { + const options = optionsFromParameter("useJsonWireFormat=true"); expect(options).toMatchObject({ useJsonWireFormat: false, }); }); - it('useJsonWireFormat implies useDate=string and stringEnums=true', () => { - const options = optionsFromParameter('useJsonWireFormat=true,onlyTypes=true'); + it("useJsonWireFormat implies useDate=string and stringEnums=true", () => { + const options = optionsFromParameter("useJsonWireFormat=true,onlyTypes=true"); expect(options).toMatchObject({ useJsonWireFormat: true, onlyTypes: true, diff --git a/tests/types-test.ts b/tests/types-test.ts index fbdb25810..18038af30 100644 --- a/tests/types-test.ts +++ b/tests/types-test.ts @@ -1,12 +1,12 @@ -import { Options, defaultOptions } from '../src/options'; -import { messageToTypeName, TypeMap } from '../src/types'; -import { Code, code, imp } from 'ts-poet'; -import { Utils } from '../src/main'; +import { Options, defaultOptions } from "../src/options"; +import { messageToTypeName, TypeMap } from "../src/types"; +import { Code, code, imp } from "ts-poet"; +import { Utils } from "../src/main"; const fakeProto = undefined as any; -describe('types', () => { - describe('messageToTypeName', () => { +describe("types", () => { + describe("messageToTypeName", () => { type TestCase = { descr: string; typeMap: TypeMap; @@ -16,42 +16,42 @@ describe('types', () => { }; const testCases: Array = [ { - descr: 'top-level messages', - typeMap: new Map([['.namespace.Message', ['namespace', 'Message', fakeProto]]]), - protoType: '.namespace.Message', - expected: code`${imp('Message@./namespace')}`, + descr: "top-level messages", + typeMap: new Map([[".namespace.Message", ["namespace", "Message", fakeProto]]]), + protoType: ".namespace.Message", + expected: code`${imp("Message@./namespace")}`, }, { - descr: 'nested messages', - typeMap: new Map([['.namespace.Message.Inner', ['namespace', 'Message_Inner', fakeProto]]]), - protoType: '.namespace.Message.Inner', - expected: code`${imp('Message_Inner@./namespace')}`, + descr: "nested messages", + typeMap: new Map([[".namespace.Message.Inner", ["namespace", "Message_Inner", fakeProto]]]), + protoType: ".namespace.Message.Inner", + expected: code`${imp("Message_Inner@./namespace")}`, }, { - descr: 'nested messages: .js import suffix', - typeMap: new Map([['.namespace.Message.Inner', ['namespace', 'Message_Inner', fakeProto]]]), - protoType: '.namespace.Message.Inner', - options: { ...defaultOptions(), importSuffix: '.js' }, - expected: code`${imp('Message_Inner@./namespace.js')}`, + descr: "nested messages: .js import suffix", + typeMap: new Map([[".namespace.Message.Inner", ["namespace", "Message_Inner", fakeProto]]]), + protoType: ".namespace.Message.Inner", + options: { ...defaultOptions(), importSuffix: ".js" }, + expected: code`${imp("Message_Inner@./namespace.js")}`, }, { - descr: 'value types', + descr: "value types", typeMap: new Map(), - protoType: '.google.protobuf.StringValue', + protoType: ".google.protobuf.StringValue", expected: code`string | undefined`, }, { - descr: 'value types (useOptionals=true)', + descr: "value types (useOptionals=true)", typeMap: new Map(), - protoType: '.google.protobuf.StringValue', + protoType: ".google.protobuf.StringValue", options: { ...defaultOptions(), useOptionals: true }, expected: code`string`, }, { descr: 'value types (useOptionals="all")', typeMap: new Map(), - protoType: '.google.protobuf.StringValue', - options: { ...defaultOptions(), useOptionals: 'all' }, + protoType: ".google.protobuf.StringValue", + options: { ...defaultOptions(), useOptionals: "all" }, expected: code`string`, }, ]; diff --git a/tests/utils-test.ts b/tests/utils-test.ts index 19d92569b..5b4b2c8df 100644 --- a/tests/utils-test.ts +++ b/tests/utils-test.ts @@ -1,37 +1,37 @@ -import { maybeAddComment } from '../src/utils'; -import { Code, joinCode } from 'ts-poet'; +import { maybeAddComment } from "../src/utils"; +import { Code, joinCode } from "ts-poet"; -describe('utils', () => { - describe('maybeAddComment', () => { - it('handles single-line impl comments', () => { +describe("utils", () => { + describe("maybeAddComment", () => { + it("handles single-line impl comments", () => { // Foo const chunks: Code[] = []; - maybeAddComment({ leadingComments: ' Foo\n' }, chunks); + maybeAddComment({ leadingComments: " Foo\n" }, chunks); expect(joinCode(chunks).toCodeString()).toMatchInlineSnapshot(`"/** Foo */"`); }); - it('handles single-dot star comments', () => { + it("handles single-dot star comments", () => { // /* Foo */ const chunks: Code[] = []; - maybeAddComment({ leadingComments: ' Foo ' }, chunks); + maybeAddComment({ leadingComments: " Foo " }, chunks); expect(joinCode(chunks).toCodeString()).toMatchInlineSnapshot(`"/** Foo */"`); }); - it('handles single-line double-dot star comments', () => { + it("handles single-line double-dot star comments", () => { // /** Foo */ const chunks: Code[] = []; - maybeAddComment({ leadingComments: ' * Foo ' }, chunks); + maybeAddComment({ leadingComments: " * Foo " }, chunks); expect(joinCode(chunks).toCodeString()).toMatchInlineSnapshot(`"/** Foo */"`); }); - it('handles double-line double-dot star comments', () => { + it("handles double-line double-dot star comments", () => { // /** // * Foo // * // * bar. // */ const chunks: Code[] = []; - maybeAddComment({ leadingComments: '*\n Foo\n \n bar.\n' }, chunks); + maybeAddComment({ leadingComments: "*\n Foo\n \n bar.\n" }, chunks); expect(joinCode(chunks).toCodeString()).toMatchInlineSnapshot(` "/** * Foo @@ -41,11 +41,11 @@ describe('utils', () => { `); }); - it('handles double-line impl comments', () => { + it("handles double-line impl comments", () => { // // Foo // // Bar const chunks: Code[] = []; - maybeAddComment({ leadingComments: ' Foo\n Bar\n' }, chunks); + maybeAddComment({ leadingComments: " Foo\n Bar\n" }, chunks); expect(joinCode(chunks).toCodeString()).toMatchInlineSnapshot(` "/** * Foo diff --git a/yarn.lock b/yarn.lock index 656d78c81..95672a295 100644 --- a/yarn.lock +++ b/yarn.lock @@ -338,12 +338,34 @@ resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== -"@cspotcode/source-map-support@^0.8.0": - version "0.8.1" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" - integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== +"@esbuild-kit/cjs-loader@^2.3.3": + version "2.3.3" + resolved "https://registry.yarnpkg.com/@esbuild-kit/cjs-loader/-/cjs-loader-2.3.3.tgz#d65a8cc099d88ac58a571403428d82d1a791aefa" + integrity sha512-Rt4O1mXlPEDVxvjsHLgbtHVdUXYK9C1/6ThpQnt7FaXIjUOsI6qhHYMgALhNnlIMZffag44lXd6Dqgx3xALbpQ== dependencies: - "@jridgewell/trace-mapping" "0.3.9" + "@esbuild-kit/core-utils" "^2.1.0" + get-tsconfig "^4.1.0" + +"@esbuild-kit/core-utils@^2.1.0": + version "2.3.0" + resolved "https://registry.yarnpkg.com/@esbuild-kit/core-utils/-/core-utils-2.3.0.tgz#b1e979fb19d23c71cf8815e3bcd0e792d9c9049d" + integrity sha512-JL73zt/LN/qqziHuod4/bM2xBNNofDZu1cbwT6KIn6B11lA4cgDXkoSHOfNCbZMZOnh0Aqf0vW/gNQC+Z18hKQ== + dependencies: + esbuild "~0.15.4" + source-map-support "^0.5.21" + +"@esbuild-kit/esm-loader@^2.4.2": + version "2.4.2" + resolved "https://registry.yarnpkg.com/@esbuild-kit/esm-loader/-/esm-loader-2.4.2.tgz#b358112c6592f422cc43c0439396537481518412" + integrity sha512-N9dPKAj8WOx6djVnStgILWXip4fjDcBk9L7azO0/uQDpu8Ee0eaL78mkN4Acid9BzvNAKWwdYXFJZnsVahNEew== + dependencies: + "@esbuild-kit/core-utils" "^2.1.0" + get-tsconfig "^4.1.0" + +"@esbuild/linux-loong64@0.15.5": + version "0.15.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.15.5.tgz#91aef76d332cdc7c8942b600fa2307f3387e6f82" + integrity sha512-UHkDFCfSGTuXq08oQltXxSZmH1TXyWsL+4QhZDWvvLl6mEJQqk3u7/wq1LjhrrAXYIllaTtRSzUXl4Olkf2J8A== "@gar/promisify@^1.1.3": version "1.1.3" @@ -655,14 +677,6 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== -"@jridgewell/trace-mapping@0.3.9": - version "0.3.9" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" - integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - "@jridgewell/trace-mapping@^0.3.12", "@jridgewell/trace-mapping@^0.3.13", "@jridgewell/trace-mapping@^0.3.9": version "0.3.14" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.14.tgz#b231a081d8f66796e475ad588a1ef473112701ed" @@ -1385,26 +1399,6 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== -"@tsconfig/node10@^1.0.7": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" - integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== - -"@tsconfig/node12@^1.0.7": - version "1.0.11" - resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" - integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== - -"@tsconfig/node14@^1.0.0": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" - integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== - -"@tsconfig/node16@^1.0.2": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e" - integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ== - "@types/babel__core@^7.1.14": version "7.1.19" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.19.tgz#7b497495b7d1b4812bdb9d02804d0576f43ee460" @@ -1591,16 +1585,6 @@ abort-controller@^3.0.0: dependencies: event-target-shim "^5.0.0" -acorn-walk@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - -acorn@^8.4.1: - version "8.7.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" - integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== - agent-base@6, agent-base@^6.0.2: version "6.0.2" resolved "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz" @@ -1749,11 +1733,6 @@ are-we-there-yet@~1.1.2: delegates "^1.0.0" readable-stream "^2.0.6" -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - argparse@^1.0.7: version "1.0.10" resolved "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz" @@ -2468,11 +2447,6 @@ cosmiconfig@^7.0.0: path-type "^4.0.0" yaml "^1.10.0" -create-require@^1.1.0: - version "1.1.1" - resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz" - integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== - cross-spawn@^7.0.0, cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz" @@ -2590,6 +2564,11 @@ deprecation@^2.0.0, deprecation@^2.3.1: resolved "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz" integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== +detect-libc@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + integrity sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg== + detect-newline@^3.0.0: version "3.1.0" resolved "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz" @@ -2613,11 +2592,6 @@ diff-sequences@^28.1.1: resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-28.1.1.tgz#9989dc731266dc2903457a70e996f3a041913ac6" integrity sha512-FU0iFaH/E23a+a718l8Qa/19bF9p06kgE0KipMOMadwa3SjnaElKzPaUC0vnibs6/B/9ni97s61mcejk8W1fQw== -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - diff@^5.0.0: version "5.0.0" resolved "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz" @@ -2637,6 +2611,13 @@ dot-prop@^5.1.0: dependencies: is-obj "^2.0.0" +dprint-node@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/dprint-node/-/dprint-node-1.0.7.tgz#f571eaf61affb3a696cff1bdde78a021875ba540" + integrity sha512-NTZOW9A7ipb0n7z7nC3wftvsbceircwVHSgzobJsEQa+7RnOMbhrfX5IflA6CtC4GA63DSAiHYXa4JKEy9F7cA== + dependencies: + detect-libc "^1.0.3" + duplexer2@~0.1.0: version "0.1.4" resolved "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz" @@ -2713,6 +2694,133 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" +esbuild-android-64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-android-64/-/esbuild-android-64-0.15.5.tgz#3c7b2f2a59017dab3f2c0356188a8dd9cbdc91c8" + integrity sha512-dYPPkiGNskvZqmIK29OPxolyY3tp+c47+Fsc2WYSOVjEPWNCHNyqhtFqQadcXMJDQt8eN0NMDukbyQgFcHquXg== + +esbuild-android-arm64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.15.5.tgz#e301db818c5a67b786bf3bb7320e414ac0fcf193" + integrity sha512-YyEkaQl08ze3cBzI/4Cm1S+rVh8HMOpCdq8B78JLbNFHhzi4NixVN93xDrHZLztlocEYqi45rHHCgA8kZFidFg== + +esbuild-darwin-64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-darwin-64/-/esbuild-darwin-64-0.15.5.tgz#11726de5d0bf5960b92421ef433e35871c091f8d" + integrity sha512-Cr0iIqnWKx3ZTvDUAzG0H/u9dWjLE4c2gTtRLz4pqOBGjfjqdcZSfAObFzKTInLLSmD0ZV1I/mshhPoYSBMMCQ== + +esbuild-darwin-arm64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.5.tgz#ad89dafebb3613fd374f5a245bb0ce4132413997" + integrity sha512-WIfQkocGtFrz7vCu44ypY5YmiFXpsxvz2xqwe688jFfSVCnUsCn2qkEVDo7gT8EpsLOz1J/OmqjExePL1dr1Kg== + +esbuild-freebsd-64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.5.tgz#6bfb52b4a0d29c965aa833e04126e95173289c8a" + integrity sha512-M5/EfzV2RsMd/wqwR18CELcenZ8+fFxQAAEO7TJKDmP3knhWSbD72ILzrXFMMwshlPAS1ShCZ90jsxkm+8FlaA== + +esbuild-freebsd-arm64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.5.tgz#38a3fed8c6398072f9914856c7c3e3444f9ef4dd" + integrity sha512-2JQQ5Qs9J0440F/n/aUBNvY6lTo4XP/4lt1TwDfHuo0DY3w5++anw+jTjfouLzbJmFFiwmX7SmUhMnysocx96w== + +esbuild-linux-32@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-linux-32/-/esbuild-linux-32-0.15.5.tgz#942dc70127f0c0a7ea91111baf2806e61fc81b32" + integrity sha512-gO9vNnIN0FTUGjvTFucIXtBSr1Woymmx/aHQtuU+2OllGU6YFLs99960UD4Dib1kFovVgs59MTXwpFdVoSMZoQ== + +esbuild-linux-64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-linux-64/-/esbuild-linux-64-0.15.5.tgz#6d748564492d5daaa7e62420862c31ac3a44aed9" + integrity sha512-ne0GFdNLsm4veXbTnYAWjbx3shpNKZJUd6XpNbKNUZaNllDZfYQt0/zRqOg0sc7O8GQ+PjSMv9IpIEULXVTVmg== + +esbuild-linux-arm64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.5.tgz#28cd899beb2d2b0a3870fd44f4526835089a318d" + integrity sha512-7EgFyP2zjO065XTfdCxiXVEk+f83RQ1JsryN1X/VSX2li9rnHAt2swRbpoz5Vlrl6qjHrCmq5b6yxD13z6RheA== + +esbuild-linux-arm@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-linux-arm/-/esbuild-linux-arm-0.15.5.tgz#6441c256225564d8794fdef5b0a69bc1a43051b5" + integrity sha512-wvAoHEN+gJ/22gnvhZnS/+2H14HyAxM07m59RSLn3iXrQsdS518jnEWRBnJz3fR6BJa+VUTo0NxYjGaNt7RA7Q== + +esbuild-linux-mips64le@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.5.tgz#d4927f817290eaffc062446896b2a553f0e11981" + integrity sha512-KdnSkHxWrJ6Y40ABu+ipTZeRhFtc8dowGyFsZY5prsmMSr1ZTG9zQawguN4/tunJ0wy3+kD54GaGwdcpwWAvZQ== + +esbuild-linux-ppc64le@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.5.tgz#b6d660dc6d5295f89ac51c675f1a2f639e2fb474" + integrity sha512-QdRHGeZ2ykl5P0KRmfGBZIHmqcwIsUKWmmpZTOq573jRWwmpfRmS7xOhmDHBj9pxv+6qRMH8tLr2fe+ZKQvCYw== + +esbuild-linux-riscv64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.5.tgz#2801bf18414dc3d3ad58d1ea83084f00d9d84896" + integrity sha512-p+WE6RX+jNILsf+exR29DwgV6B73khEQV0qWUbzxaycxawZ8NE0wA6HnnTxbiw5f4Gx9sJDUBemh9v49lKOORA== + +esbuild-linux-s390x@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.5.tgz#12a634ae6d3384cacc2b8f4201047deafe596eae" + integrity sha512-J2ngOB4cNzmqLHh6TYMM/ips8aoZIuzxJnDdWutBw5482jGXiOzsPoEF4j2WJ2mGnm7FBCO4StGcwzOgic70JQ== + +esbuild-netbsd-64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.5.tgz#951bbf87600512dfcfbe3b8d9d117d684d26c1b8" + integrity sha512-MmKUYGDizYjFia0Rwt8oOgmiFH7zaYlsoQ3tIOfPxOqLssAsEgG0MUdRDm5lliqjiuoog8LyDu9srQk5YwWF3w== + +esbuild-openbsd-64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.5.tgz#26705b61961d525d79a772232e8b8f211fdbb035" + integrity sha512-2mMFfkLk3oPWfopA9Plj4hyhqHNuGyp5KQyTT9Rc8hFd8wAn5ZrbJg+gNcLMo2yzf8Uiu0RT6G9B15YN9WQyMA== + +esbuild-sunos-64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-sunos-64/-/esbuild-sunos-64-0.15.5.tgz#d794da1ae60e6e2f6194c44d7b3c66bf66c7a141" + integrity sha512-2sIzhMUfLNoD+rdmV6AacilCHSxZIoGAU2oT7XmJ0lXcZWnCvCtObvO6D4puxX9YRE97GodciRGDLBaiC6x1SA== + +esbuild-windows-32@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-windows-32/-/esbuild-windows-32-0.15.5.tgz#0670326903f421424be86bc03b7f7b3ff86a9db7" + integrity sha512-e+duNED9UBop7Vnlap6XKedA/53lIi12xv2ebeNS4gFmu7aKyTrok7DPIZyU5w/ftHD4MUDs5PJUkQPP9xJRzg== + +esbuild-windows-64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-windows-64/-/esbuild-windows-64-0.15.5.tgz#64f32acb7341f3f0a4d10e8ff1998c2d1ebfc0a9" + integrity sha512-v+PjvNtSASHOjPDMIai9Yi+aP+Vwox+3WVdg2JB8N9aivJ7lyhp4NVU+J0MV2OkWFPnVO8AE/7xH+72ibUUEnw== + +esbuild-windows-arm64@0.15.5: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.5.tgz#4fe7f333ce22a922906b10233c62171673a3854b" + integrity sha512-Yz8w/D8CUPYstvVQujByu6mlf48lKmXkq6bkeSZZxTA626efQOJb26aDGLzmFWx6eg/FwrXgt6SZs9V8Pwy/aA== + +esbuild@~0.15.4: + version "0.15.5" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.15.5.tgz#5effd05666f621d4ff2fe2c76a67c198292193ff" + integrity sha512-VSf6S1QVqvxfIsSKb3UKr3VhUCis7wgDbtF4Vd9z84UJr05/Sp2fRKmzC+CSPG/dNAPPJZ0BTBLTT1Fhd6N9Gg== + optionalDependencies: + "@esbuild/linux-loong64" "0.15.5" + esbuild-android-64 "0.15.5" + esbuild-android-arm64 "0.15.5" + esbuild-darwin-64 "0.15.5" + esbuild-darwin-arm64 "0.15.5" + esbuild-freebsd-64 "0.15.5" + esbuild-freebsd-arm64 "0.15.5" + esbuild-linux-32 "0.15.5" + esbuild-linux-64 "0.15.5" + esbuild-linux-arm "0.15.5" + esbuild-linux-arm64 "0.15.5" + esbuild-linux-mips64le "0.15.5" + esbuild-linux-ppc64le "0.15.5" + esbuild-linux-riscv64 "0.15.5" + esbuild-linux-s390x "0.15.5" + esbuild-netbsd-64 "0.15.5" + esbuild-openbsd-64 "0.15.5" + esbuild-sunos-64 "0.15.5" + esbuild-windows-32 "0.15.5" + esbuild-windows-64 "0.15.5" + esbuild-windows-arm64 "0.15.5" + escalade@^3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" @@ -3030,6 +3138,11 @@ get-stream@^6.0.0: resolved "https://registry.npmjs.org/get-stream/-/get-stream-6.0.0.tgz" integrity sha512-A1B3Bh1UmL0bidM/YX2NsCOTnGJePL9rO/M+Mw3m9f2gUpfokS0hi5Eah0WSUEWZdZhIZtMjkIYS7mDfOqNHbg== +get-tsconfig@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/get-tsconfig/-/get-tsconfig-4.2.0.tgz#ff368dd7104dab47bf923404eb93838245c66543" + integrity sha512-X8u8fREiYOE6S8hLbq99PeykTDoLVnxvF4DjWKJmz9xy2nNRdUcV8ZN9tniJFeKyTU3qnC9lL8n4Chd6LmVKHg== + getpass@^0.1.1: version "0.1.7" resolved "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz" @@ -4463,7 +4576,7 @@ make-dir@^3.0.0: dependencies: semver "^6.0.0" -make-error@1.x, make-error@^1.1.1: +make-error@1.x: version "1.3.6" resolved "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz" integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== @@ -5585,11 +5698,6 @@ pkg-dir@^4.2.0: dependencies: find-up "^4.0.0" -prettier@^2.5.1: - version "2.5.1" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.5.1.tgz#fff75fa9d519c54cf0fce328c1017d94546bc56a" - integrity sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg== - prettier@^2.7.1: version "2.7.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" @@ -6204,6 +6312,14 @@ source-map-support@0.5.13: buffer-from "^1.0.0" source-map "^0.6.0" +source-map-support@^0.5.21: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + source-map@^0.6.0, source-map@^0.6.1: version "0.6.1" resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz" @@ -6619,32 +6735,12 @@ ts-jest@^28.0.5: semver "7.x" yargs-parser "^21.0.1" -ts-node@^10.8.1: - version "10.8.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.8.1.tgz#ea2bd3459011b52699d7e88daa55a45a1af4f066" - integrity sha512-Wwsnao4DQoJsN034wePSg5nZiw4YKXf56mPIAeD6wVmiv+RytNSWqc2f3fKvcUoV+Yn2+yocD71VOfQHbmVX4g== - dependencies: - "@cspotcode/source-map-support" "^0.8.0" - "@tsconfig/node10" "^1.0.7" - "@tsconfig/node12" "^1.0.7" - "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.2" - acorn "^8.4.1" - acorn-walk "^8.1.1" - arg "^4.1.0" - create-require "^1.1.0" - diff "^4.0.1" - make-error "^1.1.1" - v8-compile-cache-lib "^3.0.1" - yn "3.1.1" - -ts-poet@^4.15.0: - version "4.15.0" - resolved "https://registry.yarnpkg.com/ts-poet/-/ts-poet-4.15.0.tgz#637145fa554d3b27c56541578df0ce08cd9eb328" - integrity sha512-sLLR8yQBvHzi9d4R1F4pd+AzQxBfzOSSjfxiJxQhkUoH5bL7RsAC6wgvtVUQdGqiCsyS9rT6/8X2FI7ipdir5g== +ts-poet@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ts-poet/-/ts-poet-5.0.1.tgz#1add2ae027fa779748ad315898b39d73aa56b5fa" + integrity sha512-EqLEJ+IOuLN51L3O7XzXv2AAoqApq8pYl6tC4bNeFqYC1wCZMct811B09lvQI85o51vgUhw14Pd5Q7fmfxMBqQ== dependencies: - lodash "^4.17.15" - prettier "^2.5.1" + dprint-node "^1.0.7" ts-proto-descriptors@1.7.1: version "1.7.1" @@ -6664,6 +6760,17 @@ tslib@~2.1.0: resolved "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz" integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A== +tsx@^3.8.2: + version "3.8.2" + resolved "https://registry.yarnpkg.com/tsx/-/tsx-3.8.2.tgz#5522dbe28890b63dedb659fc86fb9c5224207c5e" + integrity sha512-Jf9izq3Youry5aEarspf6Gm+v/IE2A2xP7YVhtNH1VSCpM0jjACg7C3oD5rIoLBfXWGJSZj4KKC2bwE0TgLb2Q== + dependencies: + "@esbuild-kit/cjs-loader" "^2.3.3" + "@esbuild-kit/core-utils" "^2.1.0" + "@esbuild-kit/esm-loader" "^2.4.2" + optionalDependencies: + fsevents "~2.3.2" + tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz" @@ -6799,11 +6906,6 @@ uuid@^3.3.2: resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== -v8-compile-cache-lib@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" - integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== - v8-to-istanbul@^9.0.1: version "9.0.1" resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-9.0.1.tgz#b6f994b0b5d4ef255e17a0d17dc444a9f5132fa4" @@ -7002,8 +7104,3 @@ yargs@^17.3.1: string-width "^4.2.3" y18n "^5.0.5" yargs-parser "^21.0.0" - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==