diff --git a/packages/grpc-native-core/binding.gyp b/packages/grpc-native-core/binding.gyp index 0c8148498..87dba780e 100644 --- a/packages/grpc-native-core/binding.gyp +++ b/packages/grpc-native-core/binding.gyp @@ -91,7 +91,7 @@ 'GPR_BACKWARDS_COMPATIBILITY_MODE', 'GRPC_ARES=1', 'GRPC_UV', - 'GRPC_NODE_VERSION="1.24.0"', + 'GRPC_NODE_VERSION="1.24.1"', 'CARES_STATICLIB', 'CARES_SYMBOL_HIDING' ], diff --git a/packages/grpc-native-core/build.yaml b/packages/grpc-native-core/build.yaml index 49e36fdfe..52394dc8a 100644 --- a/packages/grpc-native-core/build.yaml +++ b/packages/grpc-native-core/build.yaml @@ -1,2 +1,3 @@ settings: '#': It's possible to have node_version here as a key to override the core's version. + node_version: 1.24.1 \ No newline at end of file diff --git a/packages/grpc-native-core/deps/grpc b/packages/grpc-native-core/deps/grpc index 16fba7baa..85e22ef28 160000 --- a/packages/grpc-native-core/deps/grpc +++ b/packages/grpc-native-core/deps/grpc @@ -1 +1 @@ -Subproject commit 16fba7baa0a35d9028f1cd9827c907be7d97269e +Subproject commit 85e22ef28d55f27e8efb3d5e2e43ca6f59971065 diff --git a/packages/grpc-native-core/index.d.ts b/packages/grpc-native-core/index.d.ts index 924d07303..25815ce64 100644 --- a/packages/grpc-native-core/index.d.ts +++ b/packages/grpc-native-core/index.d.ts @@ -1,3 +1,4 @@ + /* * Copyright 2019 gRPC authors. * @@ -15,11 +16,50 @@ * */ +/// + declare module "grpc" { - import { Message, Service as ProtobufService } from "protobufjs"; + // add imports here, inside the "grpc" module, to keep it as an ambient module + 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 @@ -83,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; } /** @@ -341,7 +381,7 @@ declare module "grpc" { /** * An EventEmitter. Used for unary calls. */ - export class ServerUnaryCall { + export class ServerUnaryCall extends EventEmitter { /** * Indicates if the call has been cancelled */ @@ -1231,7 +1271,7 @@ declare module "grpc" { /** * An EventEmitter. Used for unary calls. */ - export class ClientUnaryCall { + export class ClientUnaryCall extends EventEmitter { private constructor(); /** diff --git a/packages/grpc-native-core/index.js b/packages/grpc-native-core/index.js index 9134667a8..9534c7d4f 100644 --- a/packages/grpc-native-core/index.js +++ b/packages/grpc-native-core/index.js @@ -312,7 +312,9 @@ exports.Client = client.Client; * @memberof grpc * @param {string} target The address of the server to connect to * @param {grpc.ChannelCredentials} credentials Channel credentials to use when connecting - * @param {grpc~ChannelOptions} options A map of channel options that will be passed to the core + * @param {grpc~ChannelOptions} options A map of channel options that will be passed to the core. + * The available options are listed in + * [this document]{@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html}. */ exports.Channel = grpc.Channel; diff --git a/packages/grpc-native-core/package.json b/packages/grpc-native-core/package.json index 707228c7d..63ce5cc8c 100644 --- a/packages/grpc-native-core/package.json +++ b/packages/grpc-native-core/package.json @@ -1,6 +1,6 @@ { "name": "grpc", - "version": "1.24.0", + "version": "1.24.1", "author": "Google Inc.", "description": "gRPC Library for Node", "homepage": "https://grpc.io/", @@ -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", @@ -75,6 +76,8 @@ "deps/grpc/third_party/nanopb/*.{c,cc,h}", "deps/grpc/third_party/upb/**/*.{c,h,inc}", "deps/grpc/third_party/zlib/**/*.{c,cc,h}", + "deps/grpc/third_party/address_sorting/**/*.{c,h}", + "deps/grpc/third_party/cares/**/*.{c,h}", "binding.gyp" ], "main": "index.js", diff --git a/packages/grpc-native-core/src/client.js b/packages/grpc-native-core/src/client.js index 256f8d1cd..faba6decb 100644 --- a/packages/grpc-native-core/src/client.js +++ b/packages/grpc-native-core/src/client.js @@ -353,6 +353,42 @@ ClientDuplexStream.prototype.getPeer = getPeer; * should be used to make this particular call. */ +/** + * Properties of a call, for use with a {@link grpc.Client~callInvocationTransformer}. + * @typedef {Object} grpc.Client~CallProperties + * @property {*} argument The call argument. Only preset if the method is unary or server streaming. + * @property {grpc.Metadata} metadata The request metadata + * @property {grpc~Call} call The call object that will be returned by the client method + * @property {grpc.Channel} channel The channel that will be used to make a request + * @property {grpc~MethodDefinition} methodDefinition The MethodDefinition object that describes this method + * @property {grpc.Client~CallOptions} options The call options passed when making this request + * @property {grpc.Client~requestCallback} callback The callback that will handle the response. + * Only present if this method is unary or client streaming. + */ + +/** + * Call invocation transformer. Has access to the full call properties before a + * call is processed and can modify most of those properties. Some modifications + * will have no effect or may cause problems. + * @name grpc.Client~callInvocationTransformer + * @function + * @param {grpc.Client~CallProperties} callProperties The original call properties + * @return {grpc.Client~CallProperties} The modified call properties. + */ + +/** + * A function that functionally replaces the Channel constructor. + * @name grpc.Client~channelFactory + * @function + * @param {string} target The address of the server to connect to + * @param {grpc.ChannelCredentials} credentials Channel credentials to use when connecting + * @param {grpc~ChannelOptions} options A map of channel options that will be passed to the core. + * The available options are listed in + * [this document]{@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html}. + * @returns {grpc.Channel} This can either be an actual channel object, or an object with the + * same API. + */ + /** * A generic gRPC client. Primarily useful as a base class for generated clients * @memberof grpc @@ -360,7 +396,19 @@ ClientDuplexStream.prototype.getPeer = getPeer; * @param {string} address Server address to connect to * @param {grpc.credentials~ChannelCredentials} credentials Credentials to use * to connect to the server - * @param {Object} options Options to apply to channel creation + * @param {Object} options Options to apply to channel creation. Any of + * [the channel arguments]{@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html} + * can be used here in addition to specific client options. + * @param {grpc~Interceptor[]} [options.interceptors] Interceptors to apply to each request + * @param {grpc~InterceptorProvider[]} [options.interceptor_providers] Interceptor providers + * to apply interceptors to each request depending on the method definition. At most + * one of the interceptors and interceptor_providers options may be set. + * @param {grpc.Client~callInvocationTransformer=} options.callInvocationTransformer + * @param {grpc.Channel=} options.channelOverride Channel to use instead of constructing a new one. + * If set, the address, credentials, channel arguments options, and channelFactoryOverride + * option will all be ignored. + * @param {grpc.Client~channelFactory} options.channelFactoryOverride Function to use instead of + * the Channel constructor when creating the Client's channel. */ function Client(address, credentials, options) { var self = this; diff --git a/packages/grpc-native-core/src/server.js b/packages/grpc-native-core/src/server.js index 4b0aa3afb..737e43140 100644 --- a/packages/grpc-native-core/src/server.js +++ b/packages/grpc-native-core/src/server.js @@ -722,7 +722,8 @@ var streamHandlers = { * @memberof grpc * @constructor * @param {Object=} options Options that should be passed to the internal server - * implementation + * implementation. The available options are listed in + * [this document]{@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html}. * @example * var server = new grpc.Server(); * server.addProtoService(protobuf_service_descriptor, service_implementation); diff --git a/packages/grpc-native-core/templates/package.json.template b/packages/grpc-native-core/templates/package.json.template index e99437f49..3a1d98700 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", @@ -77,6 +78,8 @@ "deps/grpc/third_party/nanopb/*.{c,cc,h}", "deps/grpc/third_party/upb/**/*.{c,h,inc}", "deps/grpc/third_party/zlib/**/*.{c,cc,h}", + "deps/grpc/third_party/address_sorting/**/*.{c,h}", + "deps/grpc/third_party/cares/**/*.{c,h}", "binding.gyp" ], "main": "index.js", diff --git a/packages/grpc-native-core/tools/run_tests/artifacts/build_artifact_electron.bat b/packages/grpc-native-core/tools/run_tests/artifacts/build_artifact_electron.bat index 89e387300..229d0f42d 100644 --- a/packages/grpc-native-core/tools/run_tests/artifacts/build_artifact_electron.bat +++ b/packages/grpc-native-core/tools/run_tests/artifacts/build_artifact_electron.bat @@ -14,7 +14,7 @@ set arch_list=ia32 x64 -set electron_versions=1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 3.0.0 3.1.0 4.1.0 4.2.0 5.0.0 +set electron_versions=1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 3.0.0 3.1.0 4.1.0 4.2.0 5.0.0 6.0.0 set PATH=%PATH%;C:\Program Files\nodejs\;%APPDATA%\npm diff --git a/packages/grpc-native-core/tools/run_tests/artifacts/build_artifact_electron.sh b/packages/grpc-native-core/tools/run_tests/artifacts/build_artifact_electron.sh index 72c9b36f7..a226a5a98 100755 --- a/packages/grpc-native-core/tools/run_tests/artifacts/build_artifact_electron.sh +++ b/packages/grpc-native-core/tools/run_tests/artifacts/build_artifact_electron.sh @@ -16,7 +16,7 @@ set -ex arch_list=( ia32 x64 ) -electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 3.0.0 3.1.0 4.1.0 4.2.0 5.0.0 ) +electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 3.0.0 3.1.0 4.1.0 4.2.0 5.0.0 6.0.0 ) umask 022 diff --git a/test/kokoro/windows-build-electron.cfg b/test/kokoro/windows-build-electron.cfg index 873b734a9..7017d0aec 100644 --- a/test/kokoro/windows-build-electron.cfg +++ b/test/kokoro/windows-build-electron.cfg @@ -16,4 +16,4 @@ # Location of the continuous shell script in repository. build_file: "grpc-node/tools/release/kokoro-electron.bat" -timeout_mins: 60 +timeout_mins: 120 diff --git a/tools/release/kokoro-electron.bat b/tools/release/kokoro-electron.bat index 4bc1d0a21..c27db4806 100644 --- a/tools/release/kokoro-electron.bat +++ b/tools/release/kokoro-electron.bat @@ -20,7 +20,7 @@ SET PATH=%APPDATA%\nvm-ps;%APPDATA%\nvm-ps\nodejs;%PATH% call nvm install 10 call nvm use 10 -call npm install -g npm +call npm install -g npm@6.10.x @rem https://github.com/mapbox/node-pre-gyp/issues/362 call npm install -g node-gyp@3 diff --git a/tools/release/kokoro-nodejs.bat b/tools/release/kokoro-nodejs.bat index 0655d2dfb..faa6364ac 100644 --- a/tools/release/kokoro-nodejs.bat +++ b/tools/release/kokoro-nodejs.bat @@ -20,7 +20,7 @@ SET PATH=%APPDATA%\nvm-ps;%APPDATA%\nvm-ps\nodejs;%PATH% call nvm install 10 call nvm use 10 -call npm install -g npm +call npm install -g npm@6.10.x @rem https://github.com/mapbox/node-pre-gyp/issues/362 call npm install -g node-gyp@3