Socket
Socket
Sign inDemoInstall

@google-cloud/firestore

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/firestore - npm Package Compare versions

Comparing version 6.0.0 to 6.1.0-pre.0

build/src/backoff.js.map

2

build/src/bulk-writer.d.ts

@@ -17,3 +17,3 @@ /*!

import * as firestore from '@google-cloud/firestore';
import { GoogleError } from 'google-gax';
import type { GoogleError } from 'google-gax';
import { FieldPath, Firestore } from '.';

@@ -20,0 +20,0 @@ import { RateLimiter } from './rate-limiter';

@@ -191,3 +191,3 @@ "use strict";

else {
const error = new (require('google-gax').GoogleError)(status.message || undefined);
const error = new (require('google-gax/build/src/fallback').GoogleError)(status.message || undefined);
error.code = status.code;

@@ -194,0 +194,0 @@ this.pendingOps[i].onError((0, util_1.wrapError)(error, stack));

@@ -74,3 +74,4 @@ "use strict";

request.partitionCount = desiredPartitionCount - 1;
const stream = await this.firestore.requestStream('partitionQueryStream', request, tag);
const stream = await this.firestore.requestStream('partitionQueryStream',
/* bidirectional= */ false, request, tag);
stream.resume();

@@ -77,0 +78,0 @@ for await (const currentCursor of stream) {

@@ -89,3 +89,4 @@ "use strict";

try {
const stream = await this.firestore.requestStream('batchGetDocuments', request, requestTag);
const stream = await this.firestore.requestStream('batchGetDocuments',
/* bidirectional= */ false, request, requestTag);
stream.resume();

@@ -92,0 +93,0 @@ for await (const response of stream) {

@@ -280,2 +280,10 @@ /*!

/**
* Preloaded instance of google-gax (full module, with gRPC support).
*/
private _gax?;
/**
* Preloaded instance of google-gax HTTP fallback implementation (no gRPC).
*/
private _gaxFallback?;
/**
* The configuration options for the GAPIC client.

@@ -883,2 +891,4 @@ * @private

* takes a request and GAX options.
* @param bidrectional Whether the request is bidirectional (true) or
* unidirectional (false_
* @param request The Protobuf request to send.

@@ -888,3 +898,3 @@ * @param requestTag A unique client-assigned identifier for this request.

*/
requestStream(methodName: FirestoreStreamingMethod, request: {}, requestTag: string): Promise<Duplex>;
requestStream(methodName: FirestoreStreamingMethod, bidrectional: boolean, request: {}, requestTag: string): Promise<Duplex>;
}

@@ -891,0 +901,0 @@ /**

@@ -438,5 +438,24 @@ "use strict";

this._clientPool = new pool_1.ClientPool(MAX_CONCURRENT_REQUESTS_PER_CLIENT, maxIdleChannels,
/* clientFactory= */ () => {
/* clientFactory= */ (requiresGrpc) => {
var _a;
let client;
// Use the rest fallback if enabled and if the method does not require GRPC
const useFallback = !this._settings.preferRest || requiresGrpc ? false : 'rest';
let gax;
if (useFallback) {
if (!this._gaxFallback) {
gax = this._gaxFallback = require('google-gax/build/src/fallback');
}
else {
gax = this._gaxFallback;
}
}
else {
if (!this._gax) {
gax = this._gax = require('google-gax');
}
else {
gax = this._gax;
}
}
if (this._settings.ssl === false) {

@@ -448,6 +467,10 @@ const grpcModule = (_a = this._settings.grpc) !== null && _a !== void 0 ? _a : require('google-gax').grpc;

...this._settings,
});
fallback: useFallback,
}, gax);
}
else {
client = new module.exports.v1(this._settings);
client = new module.exports.v1({
...this._settings,
fallback: useFallback,
}, gax);
}

@@ -545,2 +568,9 @@ (0, logger_1.logger)('Firestore', null, 'Initialized Firestore GAPIC Client');

this._settings = settings;
this._settings.toJson = function () {
const temp = Object.assign({}, this);
if (temp.credentials) {
temp.credentials = { private_key: '***', client_email: '***' };
}
return temp;
};
this._serializer = new serializer_1.Serializer(this);

@@ -1091,3 +1121,4 @@ }

try {
this._projectId = await this._clientPool.run(requestTag, gapicClient => gapicClient.getProjectId());
this._projectId = await this._clientPool.run(requestTag,
/* requiresGrpc= */ false, gapicClient => gapicClient.getProjectId());
(0, logger_1.logger)('Firestore.initializeIfNeeded', null, 'Detected project ID: %s', this._projectId);

@@ -1119,3 +1150,4 @@ }

const retryParams = (0, util_1.getRetryParams)(methodName);
callOptions.retry = new (require('google-gax').RetryOptions)(retryCodes, retryParams);
callOptions.retry =
new (require('google-gax/build/src/fallback').RetryOptions)(retryCodes, retryParams);
}

@@ -1261,3 +1293,4 @@ return callOptions;

const callOptions = this.createCallOptions(methodName, retryCodes);
return this._clientPool.run(requestTag, async (gapicClient) => {
return this._clientPool.run(requestTag,
/* requiresGrpc= */ false, async (gapicClient) => {
try {

@@ -1286,2 +1319,4 @@ (0, logger_1.logger)('Firestore.request', requestTag, 'Sending request: %j', request);

* takes a request and GAX options.
* @param bidrectional Whether the request is bidirectional (true) or
* unidirectional (false_
* @param request The Protobuf request to send.

@@ -1291,3 +1326,3 @@ * @param requestTag A unique client-assigned identifier for this request.

*/
requestStream(methodName, request, requestTag) {
requestStream(methodName, bidrectional, request, requestTag) {
const callOptions = this.createCallOptions(methodName);

@@ -1297,3 +1332,3 @@ const bidirectional = methodName === 'listen';

const result = new util_1.Deferred();
this._clientPool.run(requestTag, async (gapicClient) => {
this._clientPool.run(requestTag, bidrectional, async (gapicClient) => {
(0, logger_1.logger)('Firestore.requestStream', requestTag, 'Sending request: %j', request);

@@ -1300,0 +1335,0 @@ try {

@@ -33,2 +33,3 @@ /*!

private readonly clientDestructor;
private grpcEnabled;
/**

@@ -64,3 +65,3 @@ * Stores each active clients and how many operations it has outstanding.

*/
constructor(concurrentOperationLimit: number, maxIdleClients: number, clientFactory: () => T, clientDestructor?: (client: T) => Promise<void>);
constructor(concurrentOperationLimit: number, maxIdleClients: number, clientFactory: (requiresGrpc: boolean) => T, clientDestructor?: (client: T) => Promise<void>);
/**

@@ -116,4 +117,4 @@ * Returns an already existing client if it has less than the maximum number

*/
run<V>(requestTag: string, op: (client: T) => Promise<V>): Promise<V>;
run<V>(requestTag: string, requiresGrpc: boolean, op: (client: T) => Promise<V>): Promise<V>;
terminate(): Promise<void>;
}

@@ -50,2 +50,3 @@ "use strict";

this.clientDestructor = clientDestructor;
this.grpcEnabled = false;
/**

@@ -79,6 +80,6 @@ * Stores each active clients and how many operations it has outstanding.

*/
acquire(requestTag) {
acquire(requestTag, requiresGrpc) {
let selectedClient = null;
let selectedClientRequestCount = -1;
for (const [client, requestCount] of this.activeClients) {
for (const [client, metadata] of this.activeClients) {
// Use the "most-full" client that can still accommodate the request

@@ -88,6 +89,7 @@ // in order to maximize the number of idle clients as operations start to

if (!this.failedClients.has(client) &&
requestCount > selectedClientRequestCount &&
requestCount < this.concurrentOperationLimit) {
metadata.activeRequestCount > selectedClientRequestCount &&
metadata.activeRequestCount < this.concurrentOperationLimit &&
(!requiresGrpc || metadata.grpcEnabled)) {
selectedClient = client;
selectedClientRequestCount = requestCount;
selectedClientRequestCount = metadata.activeRequestCount;
}

@@ -100,7 +102,10 @@ }

(0, logger_1.logger)('ClientPool.acquire', requestTag, 'Creating a new client');
selectedClient = this.clientFactory();
selectedClient = this.clientFactory(requiresGrpc);
selectedClientRequestCount = 0;
assert(!this.activeClients.has(selectedClient), 'The provided client factory returned an existing instance');
}
this.activeClients.set(selectedClient, selectedClientRequestCount + 1);
this.activeClients.set(selectedClient, {
grpcEnabled: requiresGrpc,
activeRequestCount: selectedClientRequestCount + 1,
});
return selectedClient;

@@ -115,5 +120,8 @@ }

async release(requestTag, client) {
const requestCount = this.activeClients.get(client) || 0;
assert(requestCount > 0, 'No active requests');
this.activeClients.set(client, requestCount - 1);
const metadata = this.activeClients.get(client);
assert(metadata && metadata.activeRequestCount > 0, 'No active requests');
this.activeClients.set(client, {
grpcEnabled: metadata.grpcEnabled,
activeRequestCount: metadata.activeRequestCount - 1,
});
if (this.terminated && this.opCount === 0) {

@@ -136,6 +144,11 @@ this.terminateDeferred.resolve();

shouldGarbageCollectClient(client) {
// Don't garbage collect clients that have active requests.
if (this.activeClients.get(client) !== 0) {
const clientMetadata = this.activeClients.get(client);
if (clientMetadata.activeRequestCount !== 0) {
// Don't garbage collect clients that have active requests.
return false;
}
if (this.grpcEnabled !== clientMetadata.grpcEnabled) {
// We are transitioning to GRPC. Garbage collect REST clients.
return true;
}
// Idle clients that have received RST_STREAM errors are always garbage

@@ -147,6 +160,7 @@ // collected.

// Otherwise, only garbage collect if we have too much idle capacity (e.g.
// more than 100 idle capacity with default settings) .
// more than 100 idle capacity with default settings).
let idleCapacityCount = 0;
for (const [, count] of this.activeClients) {
idleCapacityCount += this.concurrentOperationLimit - count;
for (const [, metadata] of this.activeClients) {
idleCapacityCount +=
this.concurrentOperationLimit - metadata.activeRequestCount;
}

@@ -176,3 +190,3 @@ return (idleCapacityCount > this.maxIdleClients * this.concurrentOperationLimit);

let activeOperationCount = 0;
this.activeClients.forEach(count => (activeOperationCount += count));
this.activeClients.forEach(metadata => (activeOperationCount += metadata.activeRequestCount));
return activeOperationCount;

@@ -192,7 +206,7 @@ }

*/
run(requestTag, op) {
run(requestTag, requiresGrpc, op) {
if (this.terminated) {
return Promise.reject(new Error(exports.CLIENT_TERMINATED_ERROR_MSG));
}
const client = this.acquire(requestTag);
const client = this.acquire(requestTag, requiresGrpc);
return op(client)

@@ -199,0 +213,0 @@ .catch(async (err) => {

@@ -205,3 +205,3 @@ "use strict";

else {
let error = new (require('google-gax').GoogleError)(`${this.errorCount} ` +
let error = new (require('google-gax/build/src/fallback').GoogleError)(`${this.errorCount} ` +
`${this.errorCount !== 1 ? 'deletes' : 'delete'} ` +

@@ -208,0 +208,0 @@ 'failed. The last delete failed with: ');

@@ -17,4 +17,4 @@ /*!

import { DocumentData } from '@google-cloud/firestore';
import { GoogleError } from 'google-gax';
import { BackoffSettings } from 'google-gax/build/src/gax';
import type { GoogleError } from 'google-gax';
import type { BackoffSettings } from 'google-gax/build/src/gax';
/**

@@ -21,0 +21,0 @@ * A Promise implementation that supports deferred resolution.

@@ -144,3 +144,3 @@ "use strict";

if (!serviceConfig) {
serviceConfig = require('google-gax').constructSettings('google.firestore.v1.Firestore', gapicConfig, {}, require('google-gax').Status);
serviceConfig = require('google-gax/build/src/fallback').constructSettings('google.firestore.v1.Firestore', gapicConfig, {}, require('google-gax/build/src/status').Status);
}

@@ -167,3 +167,3 @@ return serviceConfig[methodName];

var _a, _b, _c;
return ((_c = (_b = (_a = getServiceConfig(methodName)) === null || _a === void 0 ? void 0 : _a.retry) === null || _b === void 0 ? void 0 : _b.backoffSettings) !== null && _c !== void 0 ? _c : require('google-gax').createDefaultBackoffSettings());
return ((_c = (_b = (_a = getServiceConfig(methodName)) === null || _a === void 0 ? void 0 : _a.retry) === null || _b === void 0 ? void 0 : _b.backoffSettings) !== null && _c !== void 0 ? _c : require('google-gax/build/src/fallback').createDefaultBackoffSettings());
}

@@ -170,0 +170,0 @@ exports.getRetryParams = getRetryParams;

/// <reference types="node" />
import * as gax from 'google-gax';
import { Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, LocationsClient, LocationProtos } from 'google-gax';
import type * as gax from 'google-gax';
import type { Callback, CallOptions, Descriptors, ClientOptions, LROperation, PaginationCallback, LocationsClient, LocationProtos } from 'google-gax';
import { Transform } from 'stream';

@@ -92,4 +92,11 @@ import * as protos from '../../protos/firestore_admin_v1_proto_api';

* {@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 FirestoreAdminClient({fallback: 'rest'}, gax);
* ```
*/
constructor(opts?: ClientOptions);
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
/**

@@ -96,0 +103,0 @@ * Initialize the client.

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

exports.FirestoreAdminClient = void 0;
/* global window */
const gax = require("google-gax");
const google_gax_1 = require("google-gax");
const jsonProtos = require("../../protos/admin_v1.json");

@@ -32,3 +29,2 @@ /**

const gapicConfig = require("./firestore_admin_client_config.json");
const google_gax_2 = require("google-gax");
const version = require('../../../package.json').version;

@@ -100,4 +96,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 FirestoreAdminClient({fallback: 'rest'}, gax);
* ```
*/
constructor(opts) {
constructor(opts, gaxInstance) {
var _a, _b;

@@ -123,4 +126,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.

@@ -140,3 +147,3 @@ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);

}
this.locationsClient = new google_gax_1.LocationsClient(this._gaxGrpc, opts);
this.locationsClient = new this._gaxModule.LocationsClient(this._gaxGrpc, opts);
// Determine the client header string.

@@ -235,3 +242,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;
}

@@ -289,3 +296,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;

@@ -353,3 +360,3 @@ }

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
name: request.name || '',

@@ -374,3 +381,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
name: request.name || '',

@@ -395,3 +402,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
name: request.name || '',

@@ -416,3 +423,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
name: request.name || '',

@@ -437,3 +444,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -458,3 +465,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -478,5 +485,5 @@ });

async checkCreateIndexProgress(name) {
const request = new google_gax_2.operationsProtos.google.longrunning.GetOperationRequest({ name });
const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({ name });
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createIndex, gax.createDefaultBackoffSettings());
const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.createIndex, this._gaxModule.createDefaultBackoffSettings());
return decodeOperation;

@@ -498,3 +505,3 @@ }

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
'field.name': request.field.name || '',

@@ -518,5 +525,5 @@ });

async checkUpdateFieldProgress(name) {
const request = new google_gax_2.operationsProtos.google.longrunning.GetOperationRequest({ name });
const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({ name });
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateField, gax.createDefaultBackoffSettings());
const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateField, this._gaxModule.createDefaultBackoffSettings());
return decodeOperation;

@@ -538,3 +545,3 @@ }

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
name: request.name || '',

@@ -558,5 +565,5 @@ });

async checkExportDocumentsProgress(name) {
const request = new google_gax_2.operationsProtos.google.longrunning.GetOperationRequest({ name });
const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({ name });
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.exportDocuments, gax.createDefaultBackoffSettings());
const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.exportDocuments, this._gaxModule.createDefaultBackoffSettings());
return decodeOperation;

@@ -578,3 +585,3 @@ }

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
name: request.name || '',

@@ -598,5 +605,5 @@ });

async checkImportDocumentsProgress(name) {
const request = new google_gax_2.operationsProtos.google.longrunning.GetOperationRequest({ name });
const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({ name });
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importDocuments, gax.createDefaultBackoffSettings());
const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.importDocuments, this._gaxModule.createDefaultBackoffSettings());
return decodeOperation;

@@ -618,3 +625,3 @@ }

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
'database.name': request.database.name || '',

@@ -638,5 +645,5 @@ });

async checkUpdateDatabaseProgress(name) {
const request = new google_gax_2.operationsProtos.google.longrunning.GetOperationRequest({ name });
const request = new this._gaxModule.operationsProtos.google.longrunning.GetOperationRequest({ name });
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateDatabase, gax.createDefaultBackoffSettings());
const decodeOperation = new this._gaxModule.Operation(operation, this.descriptors.longrunning.updateDatabase, this._gaxModule.createDefaultBackoffSettings());
return decodeOperation;

@@ -658,3 +665,3 @@ }

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -698,3 +705,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -743,3 +750,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -766,3 +773,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -810,3 +817,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -859,3 +866,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -862,0 +869,0 @@ });

/// <reference types="node" />
import * as gax from 'google-gax';
import { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback } from 'google-gax';
import type * as gax from 'google-gax';
import type { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback } from 'google-gax';
import { Transform } from 'stream';

@@ -67,4 +67,11 @@ import * as protos from '../../protos/firestore_v1_proto_api';

* {@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 FirestoreClient({fallback: 'rest'}, gax);
* ```
*/
constructor(opts?: ClientOptions);
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
/**

@@ -71,0 +78,0 @@ * Initialize the client.

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

exports.FirestoreClient = void 0;
/* global window */
const gax = require("google-gax");
const google_gax_1 = require("google-gax");
const stream_1 = require("stream");

@@ -79,4 +76,11 @@ const jsonProtos = require("../../protos/v1.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 FirestoreClient({fallback: 'rest'}, gax);
* ```
*/
constructor(opts) {
constructor(opts, gaxInstance) {
var _a, _b;

@@ -102,4 +106,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.

@@ -149,6 +157,6 @@ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);

this.descriptors.stream = {
batchGetDocuments: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
runQuery: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
write: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING, opts.fallback === 'rest'),
listen: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING, opts.fallback === 'rest'),
batchGetDocuments: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest'),
listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest'),
};

@@ -162,3 +170,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;
}

@@ -212,3 +220,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.'));
});

@@ -227,3 +235,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;

@@ -291,3 +299,3 @@ }

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
name: request.name || '',

@@ -312,3 +320,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
'document.name': request.document.name || '',

@@ -333,3 +341,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
name: request.name || '',

@@ -354,3 +362,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
database: request.database || '',

@@ -375,3 +383,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
database: request.database || '',

@@ -396,3 +404,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
database: request.database || '',

@@ -417,3 +425,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
database: request.database || '',

@@ -438,3 +446,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -493,3 +501,3 @@ collection_id: request.collectionId || '',

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
database: request.database || '',

@@ -542,3 +550,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -601,3 +609,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -665,3 +673,3 @@ collection_id: request.collectionId || '',

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -734,3 +742,3 @@ collection_id: request.collectionId || '',

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -758,3 +766,3 @@ collection_id: request.collectionId || '',

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -831,3 +839,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -909,3 +917,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -932,3 +940,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -974,3 +982,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -1021,3 +1029,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -1024,0 +1032,0 @@ });

/// <reference types="node" />
import * as gax from 'google-gax';
import { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback } from 'google-gax';
import type * as gax from 'google-gax';
import type { Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback } from 'google-gax';
import { Transform } from 'stream';

@@ -68,4 +68,11 @@ import * as protos from '../../protos/firestore_v1beta1_proto_api';

* {@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 FirestoreClient({fallback: 'rest'}, gax);
* ```
*/
constructor(opts?: ClientOptions);
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
/**

@@ -72,0 +79,0 @@ * Initialize the client.

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

exports.FirestoreClient = void 0;
/* global window */
const gax = require("google-gax");
const google_gax_1 = require("google-gax");
const stream_1 = require("stream");

@@ -81,4 +78,11 @@ const jsonProtos = require("../../protos/v1beta1.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 FirestoreClient({fallback: 'rest'}, gax);
* ```
*/
constructor(opts) {
constructor(opts, gaxInstance) {
var _a, _b;

@@ -104,4 +108,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.

@@ -151,6 +159,6 @@ this._gaxGrpc = new this._gaxModule.GrpcClient(opts);

this.descriptors.stream = {
batchGetDocuments: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
runQuery: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
write: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING, opts.fallback === 'rest'),
listen: new this._gaxModule.StreamDescriptor(gax.StreamType.BIDI_STREAMING, opts.fallback === 'rest'),
batchGetDocuments: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
runQuery: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.SERVER_STREAMING, opts.fallback === 'rest'),
write: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest'),
listen: new this._gaxModule.StreamDescriptor(this._gaxModule.StreamType.BIDI_STREAMING, opts.fallback === 'rest'),
};

@@ -164,3 +172,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;
}

@@ -214,3 +222,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.'));
});

@@ -229,3 +237,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;

@@ -293,3 +301,3 @@ }

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
name: request.name || '',

@@ -314,3 +322,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
'document.name': request.document.name || '',

@@ -335,3 +343,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
name: request.name || '',

@@ -356,3 +364,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
database: request.database || '',

@@ -377,3 +385,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
database: request.database || '',

@@ -398,3 +406,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
database: request.database || '',

@@ -419,3 +427,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
database: request.database || '',

@@ -440,3 +448,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -495,3 +503,3 @@ collection_id: request.collectionId || '',

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
database: request.database || '',

@@ -542,3 +550,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -601,3 +609,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -665,3 +673,3 @@ collection_id: request.collectionId || '',

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -734,3 +742,3 @@ collection_id: request.collectionId || '',

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -758,3 +766,3 @@ collection_id: request.collectionId || '',

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -828,3 +836,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -903,3 +911,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -926,3 +934,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -965,3 +973,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -1009,3 +1017,3 @@ });

options.otherArgs.headers['x-goog-request-params'] =
gax.routingHeader.fromParams({
this._gaxModule.routingHeader.fromParams({
parent: request.parent || '',

@@ -1012,0 +1020,0 @@ });

@@ -302,3 +302,4 @@ "use strict";

return this.firestore
.requestStream('listen', request, this.requestTag)
.requestStream('listen',
/* bidirectional= */ true, request, this.requestTag)
.then(backendStream => {

@@ -305,0 +306,0 @@ if (!this.isActive) {

{
"name": "@google-cloud/firestore",
"description": "Firestore Client Library for Node.js",
"version": "6.0.0",
"version": "6.1.0-pre.0",
"license": "Apache-2.0",

@@ -33,3 +33,5 @@ "author": "Google Inc.",

"docs": "jsdoc -c .jsdoc.js",
"system-test": "mocha build/system-test --timeout 600000",
"system-test:rest": "USE_REST_FALLBACK=YES mocha build/system-test --timeout 600000",
"system-test:grpc": "mocha build/system-test --timeout 600000",
"system-test": "npm run system-test:grpc && npm run system-test:rest",
"presystem-test": "npm run compile",

@@ -56,3 +58,3 @@ "samples-test": "npm link && cd samples/ && npm link ../ && npm test && cd ../",

"functional-red-black-tree": "^1.0.1",
"google-gax": "^3.0.1",
"google-gax": "^3.3.2-pre.1",
"protobufjs": "^7.0.0"

@@ -88,4 +90,4 @@ },

"ts-node": "^10.0.0",
"typescript": "^4.6.4"
"typescript": "~4.7.4"
}
}

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