New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/pubsub

Package Overview
Dependencies
Maintainers
1
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/pubsub - npm Package Compare versions

Comparing version 0.31.1 to 0.32.0

build/protos/google/iam/v1/options.proto

12

build/src/pubsub.d.ts

@@ -200,2 +200,14 @@ /*!

/**
* Get the PubSub client object.
*
* @private
*
* @param {object} config Configuration object.
* @param {object} config.gaxOpts GAX options.
* @param {function} config.method The gax method to call.
* @param {object} config.reqOpts Request options.
* @returns {Promise}
*/
getClientAsync_(config: GetClientConfig): Promise<gax.ClientStub>;
/**
* Funnel all API requests through this method, to be sure we have a project

@@ -202,0 +214,0 @@ * ID.

42

build/src/pubsub.js

@@ -329,2 +329,5 @@ "use strict";

this.isEmulator = true;
if (!this.options.projectId && process.env.PUBSUB_PROJECT_ID) {
this.options.projectId = process.env.PUBSUB_PROJECT_ID;
}
}

@@ -600,14 +603,29 @@ /**

getClient_(config, callback) {
const hasProjectId = this.projectId && this.projectId !== PROJECT_ID_PLACEHOLDER;
if (!hasProjectId && !this.isEmulator) {
this.auth.getProjectId((err, projectId) => {
if (err) {
callback(err);
return;
this.getClientAsync_(config).then(client => callback(null, client), callback);
}
/**
* Get the PubSub client object.
*
* @private
*
* @param {object} config Configuration object.
* @param {object} config.gaxOpts GAX options.
* @param {function} config.method The gax method to call.
* @param {object} config.reqOpts Request options.
* @returns {Promise}
*/
async getClientAsync_(config) {
if (!this.projectId || this.projectId === PROJECT_ID_PLACEHOLDER) {
let projectId;
try {
projectId = await this.auth.getProjectId();
}
catch (e) {
if (!this.isEmulator) {
throw e;
}
this.projectId = projectId;
this.options.projectId = projectId;
this.getClient_(config, callback);
});
return;
projectId = '';
}
this.projectId = projectId;
this.options.projectId = projectId;
}

@@ -620,3 +638,3 @@ let gaxClient = this.api[config.client];

}
callback(null, gaxClient);
return gaxClient;
}

@@ -623,0 +641,0 @@ /**

@@ -92,7 +92,9 @@ // Copyright 2019 Google LLC

* In JavaScript, one can convert a Date object to this format using the
* standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
* standard
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
* method. In Python, a standard `datetime.datetime` object can be converted
* to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
* with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
* can use the Joda Time's [`ISODateTimeFormat.dateTime()`](https://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D) to obtain a formatter capable of generating timestamps in this format.
* to this format using
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
* the Joda Time's [`ISODateTimeFormat.dateTime()`](https://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D) to obtain a formatter capable of generating timestamps in this format.
*

@@ -99,0 +101,0 @@ * @property {number} seconds

@@ -423,2 +423,17 @@ // Copyright 2019 Google LLC

*
* @property {Object} deadLetterPolicy
* A policy that specifies the conditions for dead lettering messages in
* this subscription. If dead_letter_policy is not set, dead lettering
* is disabled.
*
* The Cloud Pub/Sub service account associated with this subscriptions's
* parent project (i.e.,
* service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
* permission to Acknowledge() messages on this subscription.
* <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
* API might be changed in backward-incompatible ways and is not recommended
* for production use. It is not subject to any SLA or deprecation policy.
*
* This object should have the same structure as [DeadLetterPolicy]{@link google.pubsub.v1.DeadLetterPolicy}
*
* @typedef Subscription

@@ -433,2 +448,43 @@ * @memberof google.pubsub.v1

/**
* Dead lettering is done on a best effort basis. The same message might be
* dead lettered multiple times.
*
* If validation on any of the fields fails at subscription creation/updation,
* the create/update subscription request will fail.
*
* @property {string} deadLetterTopic
* The name of the topic to which dead letter messages should be published.
* Format is `projects/{project}/topics/{topic}`.The Cloud Pub/Sub service
* account associated with the enclosing subscription's parent project (i.e.,
* service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
* permission to Publish() to this topic.
*
* The operation will fail if the topic does not exist.
* Users should ensure that there is a subscription attached to this topic
* since messages published to a topic with no subscriptions are lost.
*
* @property {number} maxDeliveryAttempts
* The maximum number of delivery attempts for any message. The value must be
* between 5 and 100.
*
* The number of delivery attempts is defined as 1 + (the sum of number of
* NACKs and number of times the acknowledgement deadline has been exceeded
* for the message).
*
* A NACK is any call to ModifyAckDeadline with a 0 deadline. Note that
* client libraries may automatically extend ack_deadlines.
*
* This field will be honored on a best effort basis.
*
* If this parameter is 0, a default value of 5 is used.
*
* @typedef DeadLetterPolicy
* @memberof google.pubsub.v1
* @see [google.pubsub.v1.DeadLetterPolicy definition in proto format]{@link https://github.com/googleapis/googleapis/blob/master/google/pubsub/v1/pubsub.proto}
*/
const DeadLetterPolicy = {
// This is for documentation. Actual contents will be loaded by gRPC.
};
/**
* A policy that specifies the conditions for resource expiration (i.e.,

@@ -538,2 +594,20 @@ * automatic resource deletion).

*
* @property {number} deliveryAttempt
* Delivery attempt counter is 1 + (the sum of number of NACKs and number of
* ack_deadline exceeds) for this message.
*
* A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
* exceeds event is whenever a message is not acknowledged within
* ack_deadline. Note that ack_deadline is initially
* Subscription.ackDeadlineSeconds, but may get extended automatically by
* the client library.
*
* The first delivery of a given message will have this value as 1. The value
* is calculated at best effort and is approximate.
*
* If a DeadLetterPolicy is not set on the subscription, this will be 0.
* <b>EXPERIMENTAL:</b> This feature is part of a closed alpha release. This
* API might be changed in backward-incompatible ways and is not recommended
* for production use. It is not subject to any SLA or deprecation policy.
*
* @typedef ReceivedMessage

@@ -682,4 +756,5 @@ * @memberof google.pubsub.v1

* @property {number} maxMessages
* The maximum number of messages returned for this request. The Pub/Sub
* system may return fewer than the number specified.
* The maximum number of messages to return for this request. Must be a
* positive integer. The Pub/Sub system may return fewer than the number
* specified.
*

@@ -686,0 +761,0 @@ * @typedef PullRequest

@@ -20,3 +20,2 @@ // Copyright 2019 Google LLC

const path = require('path');
const protobuf = require('protobufjs');

@@ -64,2 +63,12 @@ const VERSION = require('../../../package.json').version;

if (global.isBrowser) {
// If we're in browser, we use gRPC fallback.
opts.fallback = true;
}
// If we are in browser, we are already using fallback because of the
// "browser" field in package.json.
// But if we were explicitly requested to use fallback, let's do it now.
const gaxModule = !global.isBrowser && opts.fallback ? gax.fallback : gax;
const servicePath =

@@ -81,3 +90,3 @@ opts.servicePath || opts.apiEndpoint || this.constructor.servicePath;

opts.scopes = this.constructor.scopes;
const gaxGrpc = new gax.GrpcClient(opts);
const gaxGrpc = new gaxModule.GrpcClient(opts);

@@ -88,8 +97,14 @@ // Save the auth object to the client, for use by other methods.

// Determine the client header string.
const clientHeader = [
`gl-node/${process.versions.node}`,
`grpc/${gaxGrpc.grpcVersion}`,
`gax/${gax.version}`,
`gapic/${VERSION}`,
];
const clientHeader = [];
if (typeof process !== 'undefined' && 'versions' in process) {
clientHeader.push(`gl-node/${process.versions.node}`);
}
clientHeader.push(`gax/${gaxModule.version}`);
if (opts.fallback) {
clientHeader.push(`gl-web/${gaxModule.version}`);
} else {
clientHeader.push(`grpc/${gaxGrpc.grpcVersion}`);
}
clientHeader.push(`gapic/${VERSION}`);
if (opts.libName && opts.libVersion) {

@@ -100,5 +115,14 @@ clientHeader.push(`${opts.libName}/${opts.libVersion}`);

// Load the applicable protos.
// For Node.js, pass the path to JSON proto file.
// For browsers, pass the JSON content.
const nodejsProtoPath = path.join(
__dirname,
'..',
'..',
'protos',
'protos.json'
);
const protos = gaxGrpc.loadProto(
path.join(__dirname, '..', '..', 'protos'),
['google/iam/v1/iam_policy.proto', 'google/pubsub/v1/pubsub.proto']
opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath
);

@@ -110,4 +134,4 @@

this._pathTemplates = {
projectPathTemplate: new gax.PathTemplate('projects/{project}'),
topicPathTemplate: new gax.PathTemplate(
projectPathTemplate: new gaxModule.PathTemplate('projects/{project}'),
topicPathTemplate: new gaxModule.PathTemplate(
'projects/{project}/topics/{topic}'

@@ -121,3 +145,3 @@ ),

this._descriptors.page = {
listTopics: new gax.PageDescriptor(
listTopics: new gaxModule.PageDescriptor(
'pageToken',

@@ -127,3 +151,3 @@ 'nextPageToken',

),
listTopicSubscriptions: new gax.PageDescriptor(
listTopicSubscriptions: new gaxModule.PageDescriptor(
'pageToken',

@@ -134,28 +158,11 @@ 'nextPageToken',

};
let protoFilesRoot = new gax.GoogleProtoFilesRoot();
protoFilesRoot = protobuf.loadSync(
path.join(
__dirname,
'..',
'..',
'protos',
'google/iam/v1/iam_policy.proto'
),
protoFilesRoot
);
protoFilesRoot = protobuf.loadSync(
path.join(
__dirname,
'..',
'..',
'protos',
'google/pubsub/v1/pubsub.proto'
),
protoFilesRoot
);
const protoFilesRoot = opts.fallback
? gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
: gaxModule.protobuf.loadSync(nodejsProtoPath);
// Some methods on this API support automatically batching
// requests; denote this.
this._descriptors.batching = {
publish: new gax.BundleDescriptor(
publish: new gaxModule.BundleDescriptor(
'messages',

@@ -186,3 +193,5 @@ ['topic'],

const iamPolicyStub = gaxGrpc.createStub(
protos.google.iam.v1.IAMPolicy,
opts.fallback
? protos.lookupService('google.iam.v1.IAMPolicy')
: protos.google.iam.v1.IAMPolicy,
opts

@@ -199,14 +208,12 @@ );

for (const methodName of iamPolicyStubMethods) {
this._innerApiCalls[methodName] = gax.createApiCall(
iamPolicyStub.then(
stub =>
function() {
const args = Array.prototype.slice.call(arguments, 0);
return stub[methodName].apply(stub, args);
},
err =>
function() {
throw err;
}
),
const innerCallPromise = iamPolicyStub.then(
stub => (...args) => {
return stub[methodName].apply(stub, args);
},
err => () => {
throw err;
}
);
this._innerApiCalls[methodName] = gaxModule.createApiCall(
innerCallPromise,
defaults[methodName],

@@ -221,3 +228,5 @@ this._descriptors.page[methodName] ||

const publisherStub = gaxGrpc.createStub(
protos.google.pubsub.v1.Publisher,
opts.fallback
? protos.lookupService('google.pubsub.v1.Publisher')
: protos.google.pubsub.v1.Publisher,
opts

@@ -238,14 +247,12 @@ );

for (const methodName of publisherStubMethods) {
this._innerApiCalls[methodName] = gax.createApiCall(
publisherStub.then(
stub =>
function() {
const args = Array.prototype.slice.call(arguments, 0);
return stub[methodName].apply(stub, args);
},
err =>
function() {
throw err;
}
),
const innerCallPromise = publisherStub.then(
stub => (...args) => {
return stub[methodName].apply(stub, args);
},
err => () => {
throw err;
}
);
this._innerApiCalls[methodName] = gaxModule.createApiCall(
innerCallPromise,
defaults[methodName],

@@ -252,0 +259,0 @@ this._descriptors.page[methodName] ||

@@ -7,2 +7,17 @@ # Changelog

## [0.32.0](https://www.github.com/googleapis/nodejs-pubsub/compare/v0.31.1...v0.32.0) (2019-09-11)
### Bug Fixes
* pull projectId from auth client with emulator ([#731](https://www.github.com/googleapis/nodejs-pubsub/issues/731)) ([3840cad](https://www.github.com/googleapis/nodejs-pubsub/commit/3840cad))
* update IAM protos ([#736](https://www.github.com/googleapis/nodejs-pubsub/issues/736)) ([055fa33](https://www.github.com/googleapis/nodejs-pubsub/commit/055fa33))
### Features
* introduces DeadLetterPolicy ([e24c545](https://www.github.com/googleapis/nodejs-pubsub/commit/e24c545))
* load protos from JSON, grpc-fallback support ([#730](https://www.github.com/googleapis/nodejs-pubsub/issues/730)) ([2071954](https://www.github.com/googleapis/nodejs-pubsub/commit/2071954))
* update IAM protos ([#734](https://www.github.com/googleapis/nodejs-pubsub/issues/734)) ([91fa2ef](https://www.github.com/googleapis/nodejs-pubsub/commit/91fa2ef))
### [0.31.1](https://www.github.com/googleapis/nodejs-pubsub/compare/v0.31.0...v0.31.1) (2019-08-27)

@@ -9,0 +24,0 @@

{
"name": "@google-cloud/pubsub",
"description": "Cloud Pub/Sub Client Library for Node.js",
"version": "0.31.1",
"version": "0.32.0",
"license": "Apache-2.0",

@@ -86,3 +86,3 @@ "author": "Google Inc.",

"eslint-config-prettier": "^6.0.0",
"eslint-plugin-node": "^9.0.0",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-prettier": "^3.0.0",

@@ -104,5 +104,5 @@ "gts": "^1.0.0",

"source-map-support": "^0.5.9",
"typescript": "~3.5.0",
"typescript": "~3.6.0",
"uuid": "^3.1.0"
}
}

@@ -129,3 +129,3 @@ [//]: # "This README.md file is auto-generated, all changes to this file will be lost."

[client-docs]: https://googleapis.dev/nodejs/pubsub/latest#reference
[client-docs]: https://googleapis.dev/nodejs/pubsub/latest
[product-docs]: https://cloud.google.com/pubsub/docs/

@@ -137,3 +137,1 @@ [shell_img]: https://gstatic.com/cloudssh/images/open-btn.png

[auth]: https://cloud.google.com/docs/authentication/getting-started
<a name="reference"></a>

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 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc