From d434d132fc91b341f37c8199a15ff6f941d26644 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 22 Aug 2019 13:18:36 -0700 Subject: [PATCH] Duplicate relevant protobufjs type definition --- packages/grpc-native-core/index.d.ts | 41 ++++++++++++++++++- packages/grpc-native-core/package.json | 1 + .../templates/package.json.template | 1 + 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/packages/grpc-native-core/index.d.ts b/packages/grpc-native-core/index.d.ts index 7977c727..1f936311 100644 --- a/packages/grpc-native-core/index.d.ts +++ b/packages/grpc-native-core/index.d.ts @@ -16,13 +16,50 @@ * */ +/// + declare module "grpc" { // add imports here, inside the "grpc" module, to keep it as an ambient module - import { Message, Service as ProtobufService } from "protobufjs"; import { EventEmitter } from "events"; import { Duplex, Readable, Writable } from "stream"; import { SecureContext } from "tls"; + /* The Message interface is copied and slightly modified from @types/protobuf + * version 5.0.31, which was distributed under the following license: + * + * This project is licensed under the MIT license. + * Copyrights are respective of each contributor listed at the beginning of each definition file. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + export interface ProtobufMessage { + $add(key: string, value: any, noAssert?: boolean): ProtobufMessage; + $get(key: string): T; + $set(key: string | {[key: string]: any}, value?: any | boolean, noAssert?: boolean): void; + add(key: string, value: any, noAssert?: boolean): ProtobufMessage; + calculate(): number; + encode(buffer?: ByteBuffer | boolean, noVerify?: boolean): ByteBuffer; + encode64(): string; + encodeAB(): ArrayBuffer; + encodeNB(): Buffer; + encodeHex(): string; + encodeJSON(): string; + encodeDelimited(buffer?: ByteBuffer | boolean, noVerify?: boolean): ByteBuffer; + get(key: string, noAssert?: boolean): T; + set(key: string | {[key: string]: any}, value?: any | boolean, noAssert?: boolean): void; + toArrayBuffer(): ArrayBuffer; + toBase64(): string; + toBuffer(): Buffer; + toHex(): string; + toRaw(binaryAsBase64?: boolean, longsAsStrings?: boolean): {[key: string]: any}; + toString(): string; + [field: string]: any; + } + /** * Load a ProtoBuf.js object as a gRPC object. * @param value The ProtoBuf.js reflection object to load @@ -86,7 +123,7 @@ declare module "grpc" { * - Anything else becomes the relevant reflection object that ProtoBuf.js would create */ export interface GrpcObject { - [name: string]: GrpcObject | typeof Client | Message; + [name: string]: GrpcObject | typeof Client | ProtobufMessage; } /** diff --git a/packages/grpc-native-core/package.json b/packages/grpc-native-core/package.json index 519a8279..3f691495 100644 --- a/packages/grpc-native-core/package.json +++ b/packages/grpc-native-core/package.json @@ -29,6 +29,7 @@ "node-pre-gyp" ], "dependencies": { + "@types/bytebuffer": "^5.0.40", "lodash.camelcase": "^4.3.0", "lodash.clone": "^4.5.0", "nan": "^2.13.2", diff --git a/packages/grpc-native-core/templates/package.json.template b/packages/grpc-native-core/templates/package.json.template index db054aa4..eaab7067 100644 --- a/packages/grpc-native-core/templates/package.json.template +++ b/packages/grpc-native-core/templates/package.json.template @@ -31,6 +31,7 @@ "node-pre-gyp" ], "dependencies": { + "@types/bytebuffer": "^5.0.40", "lodash.camelcase": "^4.3.0", "lodash.clone": "^4.5.0", "nan": "^2.13.2",