@google-cloud/pubsub
Advanced tools
Comparing version 3.1.0 to 3.1.1
/// <reference types="node" /> | ||
import * as gax from 'google-gax'; | ||
import { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, IamClient, IamProtos } from 'google-gax'; | ||
import type * as gax from 'google-gax'; | ||
import type { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, IamClient, IamProtos } from 'google-gax'; | ||
import { Transform } from 'stream'; | ||
@@ -65,4 +65,11 @@ import * as protos from '../../protos/protos'; | ||
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. | ||
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you | ||
* need to avoid loading the default gRPC version and want to use the fallback | ||
* HTTP implementation. Load only fallback version and pass it to the constructor: | ||
* ``` | ||
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC | ||
* const client = new PublisherClient({fallback: 'rest'}, gax); | ||
* ``` | ||
*/ | ||
constructor(opts?: ClientOptions); | ||
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback); | ||
/** | ||
@@ -69,0 +76,0 @@ * Initialize the client. |
@@ -21,5 +21,2 @@ "use strict"; | ||
exports.PublisherClient = void 0; | ||
/* global window */ | ||
const gax = require("google-gax"); | ||
const google_gax_1 = require("google-gax"); | ||
const jsonProtos = require("../../protos/protos.json"); | ||
@@ -72,4 +69,11 @@ /** | ||
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. | ||
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you | ||
* need to avoid loading the default gRPC version and want to use the fallback | ||
* HTTP implementation. Load only fallback version and pass it to the constructor: | ||
* ``` | ||
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC | ||
* const client = new PublisherClient({fallback: 'rest'}, gax); | ||
* ``` | ||
*/ | ||
constructor(opts) { | ||
constructor(opts, gaxInstance) { | ||
var _a, _b; | ||
@@ -95,4 +99,8 @@ this._terminated = false; | ||
} | ||
// Load google-gax module synchronously if needed | ||
if (!gaxInstance) { | ||
gaxInstance = require('google-gax'); | ||
} | ||
// Choose either gRPC or proto-over-HTTP implementation of google-gax. | ||
this._gaxModule = opts.fallback ? gax.fallback : gax; | ||
this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; | ||
// Create a `gaxGrpc` object, with any grpc-specific options sent to the client. | ||
@@ -112,3 +120,3 @@ this._gaxGrpc = new this._gaxModule.GrpcClient(opts); | ||
} | ||
this.iamClient = new google_gax_1.IamClient(this._gaxGrpc, opts); | ||
this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); | ||
// Determine the client header string. | ||
@@ -155,3 +163,3 @@ const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; | ||
this.descriptors.batching = { | ||
publish: new this._gaxModule.BundleDescriptor('messages', ['topic'], 'message_ids', gax.createByteLengthFunction( | ||
publish: new this._gaxModule.BundleDescriptor('messages', ['topic'], 'message_ids', this._gaxModule.GrpcClient.createByteLengthFunction( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -167,3 +175,3 @@ protoFilesRoot.lookupType('google.pubsub.v1.PubsubMessage'))), | ||
// Add a warn function to the client constructor so it can be easily tested. | ||
this.warn = gax.warn; | ||
this.warn = this._gaxModule.warn; | ||
} | ||
@@ -219,3 +227,3 @@ /** | ||
undefined; | ||
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor); | ||
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback); | ||
this.innerApiCalls[methodName] = apiCall; | ||
@@ -283,3 +291,3 @@ } | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
name: request.name || '', | ||
@@ -304,3 +312,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
'topic.name': request.topic.name || '', | ||
@@ -325,3 +333,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
topic: request.topic || '', | ||
@@ -346,3 +354,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
topic: request.topic || '', | ||
@@ -367,3 +375,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
topic: request.topic || '', | ||
@@ -388,3 +396,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
subscription: request.subscription || '', | ||
@@ -409,3 +417,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
project: request.project || '', | ||
@@ -447,3 +455,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
project: request.project || '', | ||
@@ -488,3 +496,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
project: request.project || '', | ||
@@ -511,3 +519,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
topic: request.topic || '', | ||
@@ -549,3 +557,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
topic: request.topic || '', | ||
@@ -590,3 +598,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
topic: request.topic || '', | ||
@@ -613,3 +621,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
topic: request.topic || '', | ||
@@ -651,3 +659,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
topic: request.topic || '', | ||
@@ -692,3 +700,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
topic: request.topic || '', | ||
@@ -695,0 +703,0 @@ }); |
/// <reference types="node" /> | ||
import * as gax from 'google-gax'; | ||
import { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, IamClient, IamProtos } from 'google-gax'; | ||
import type * as gax from 'google-gax'; | ||
import type { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, IamClient, IamProtos } from 'google-gax'; | ||
import { Transform } from 'stream'; | ||
@@ -64,4 +64,11 @@ import * as protos from '../../protos/protos'; | ||
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. | ||
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you | ||
* need to avoid loading the default gRPC version and want to use the fallback | ||
* HTTP implementation. Load only fallback version and pass it to the constructor: | ||
* ``` | ||
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC | ||
* const client = new SchemaServiceClient({fallback: 'rest'}, gax); | ||
* ``` | ||
*/ | ||
constructor(opts?: ClientOptions); | ||
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback); | ||
/** | ||
@@ -68,0 +75,0 @@ * Initialize the client. |
@@ -21,5 +21,2 @@ "use strict"; | ||
exports.SchemaServiceClient = void 0; | ||
/* global window */ | ||
const gax = require("google-gax"); | ||
const google_gax_1 = require("google-gax"); | ||
const jsonProtos = require("../../protos/protos.json"); | ||
@@ -71,4 +68,11 @@ /** | ||
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. | ||
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you | ||
* need to avoid loading the default gRPC version and want to use the fallback | ||
* HTTP implementation. Load only fallback version and pass it to the constructor: | ||
* ``` | ||
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC | ||
* const client = new SchemaServiceClient({fallback: 'rest'}, gax); | ||
* ``` | ||
*/ | ||
constructor(opts) { | ||
constructor(opts, gaxInstance) { | ||
var _a, _b; | ||
@@ -94,4 +98,8 @@ this._terminated = false; | ||
} | ||
// Load google-gax module synchronously if needed | ||
if (!gaxInstance) { | ||
gaxInstance = require('google-gax'); | ||
} | ||
// Choose either gRPC or proto-over-HTTP implementation of google-gax. | ||
this._gaxModule = opts.fallback ? gax.fallback : gax; | ||
this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; | ||
// Create a `gaxGrpc` object, with any grpc-specific options sent to the client. | ||
@@ -111,3 +119,3 @@ this._gaxGrpc = new this._gaxModule.GrpcClient(opts); | ||
} | ||
this.iamClient = new google_gax_1.IamClient(this._gaxGrpc, opts); | ||
this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); | ||
// Determine the client header string. | ||
@@ -155,3 +163,3 @@ const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; | ||
// Add a warn function to the client constructor so it can be easily tested. | ||
this.warn = gax.warn; | ||
this.warn = this._gaxModule.warn; | ||
} | ||
@@ -201,3 +209,3 @@ /** | ||
const descriptor = this.descriptors.page[methodName] || undefined; | ||
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor); | ||
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback); | ||
this.innerApiCalls[methodName] = apiCall; | ||
@@ -265,3 +273,3 @@ } | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
parent: request.parent || '', | ||
@@ -286,3 +294,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
name: request.name || '', | ||
@@ -307,3 +315,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
name: request.name || '', | ||
@@ -328,3 +336,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
parent: request.parent || '', | ||
@@ -349,3 +357,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
parent: request.parent || '', | ||
@@ -370,3 +378,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
parent: request.parent || '', | ||
@@ -412,3 +420,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
parent: request.parent || '', | ||
@@ -457,3 +465,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
parent: request.parent || '', | ||
@@ -460,0 +468,0 @@ }); |
@@ -21,5 +21,2 @@ "use strict"; | ||
exports.SubscriberClient = void 0; | ||
/* global window */ | ||
const gax = require("google-gax"); | ||
const google_gax_1 = require("google-gax"); | ||
const stream_1 = require("stream"); | ||
@@ -74,4 +71,11 @@ const jsonProtos = require("../../protos/protos.json"); | ||
* {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. | ||
* @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you | ||
* need to avoid loading the default gRPC version and want to use the fallback | ||
* HTTP implementation. Load only fallback version and pass it to the constructor: | ||
* ``` | ||
* const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC | ||
* const client = new SubscriberClient({fallback: 'rest'}, gax); | ||
* ``` | ||
*/ | ||
constructor(opts) { | ||
constructor(opts, gaxInstance) { | ||
var _a, _b; | ||
@@ -97,4 +101,8 @@ this._terminated = false; | ||
} | ||
// Load google-gax module synchronously if needed | ||
if (!gaxInstance) { | ||
gaxInstance = require('google-gax'); | ||
} | ||
// Choose either gRPC or proto-over-HTTP implementation of google-gax. | ||
this._gaxModule = opts.fallback ? gax.fallback : gax; | ||
this._gaxModule = opts.fallback ? gaxInstance.fallback : gaxInstance; | ||
// Create a `gaxGrpc` object, with any grpc-specific options sent to the client. | ||
@@ -114,3 +122,3 @@ this._gaxGrpc = new this._gaxModule.GrpcClient(opts); | ||
} | ||
this.iamClient = new google_gax_1.IamClient(this._gaxGrpc, opts); | ||
this.iamClient = new this._gaxModule.IamClient(this._gaxGrpc, opts); | ||
// Determine the client header string. | ||
@@ -155,3 +163,3 @@ const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; | ||
this.descriptors.stream = { | ||
streamingPull: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING, opts.fallback === 'rest'), | ||
streamingPull: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest'), | ||
}; | ||
@@ -165,3 +173,3 @@ // Put together the default options sent with requests. | ||
// Add a warn function to the client constructor so it can be easily tested. | ||
this.warn = gax.warn; | ||
this.warn = this._gaxModule.warn; | ||
} | ||
@@ -216,3 +224,3 @@ /** | ||
setImmediate(() => { | ||
stream.emit('error', new google_gax_1.GoogleError('The client has already been closed.')); | ||
stream.emit('error', new this._gaxModule.GoogleError('The client has already been closed.')); | ||
}); | ||
@@ -231,3 +239,3 @@ return stream; | ||
undefined; | ||
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor); | ||
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], descriptor, this._opts.fallback); | ||
this.innerApiCalls[methodName] = apiCall; | ||
@@ -295,3 +303,3 @@ } | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
name: request.name || '', | ||
@@ -316,3 +324,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
subscription: request.subscription || '', | ||
@@ -337,3 +345,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
'subscription.name': request.subscription.name || '', | ||
@@ -358,3 +366,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
subscription: request.subscription || '', | ||
@@ -379,3 +387,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
subscription: request.subscription || '', | ||
@@ -400,3 +408,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
subscription: request.subscription || '', | ||
@@ -421,3 +429,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
subscription: request.subscription || '', | ||
@@ -442,3 +450,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
subscription: request.subscription || '', | ||
@@ -463,3 +471,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
snapshot: request.snapshot || '', | ||
@@ -484,3 +492,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
name: request.name || '', | ||
@@ -505,3 +513,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
'snapshot.name': request.snapshot.name || '', | ||
@@ -526,3 +534,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
snapshot: request.snapshot || '', | ||
@@ -547,3 +555,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
subscription: request.subscription || '', | ||
@@ -591,3 +599,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
project: request.project || '', | ||
@@ -629,3 +637,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
project: request.project || '', | ||
@@ -670,3 +678,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
project: request.project || '', | ||
@@ -693,3 +701,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
project: request.project || '', | ||
@@ -731,3 +739,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
project: request.project || '', | ||
@@ -772,3 +780,3 @@ }); | ||
options.otherArgs.headers['x-goog-request-params'] = | ||
gax.routingHeader.fromParams({ | ||
this._gaxModule.routingHeader.fromParams({ | ||
project: request.project || '', | ||
@@ -775,0 +783,0 @@ }); |
{ | ||
"name": "@google-cloud/pubsub", | ||
"description": "Cloud Pub/Sub Client Library for Node.js", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"license": "Apache-2.0", | ||
@@ -61,3 +61,3 @@ "author": "Google Inc.", | ||
"google-auth-library": "^8.0.2", | ||
"google-gax": "^3.0.1", | ||
"google-gax": "^3.3.0", | ||
"is-stream-ended": "^0.1.4", | ||
@@ -68,3 +68,3 @@ "lodash.snakecase": "^4.1.1", | ||
"devDependencies": { | ||
"@grpc/proto-loader": "^0.6.0", | ||
"@grpc/proto-loader": "^0.7.0", | ||
"@opentelemetry/tracing": "^0.24.0", | ||
@@ -94,3 +94,3 @@ "@types/execa": "^0.9.0", | ||
"null-loader": "^4.0.0", | ||
"protobufjs": "^6.10.1", | ||
"protobufjs": "^7.0.0", | ||
"proxyquire": "^2.0.0", | ||
@@ -97,0 +97,0 @@ "sinon": "^14.0.0", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3228403
54342
Updatedgoogle-gax@^3.3.0