Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/firestore

Package Overview
Dependencies
Maintainers
1
Versions
146
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 3.8.6 to 4.0.0

build/protos/firestore/bundle.proto

68

build/src/bulk-writer.d.ts

@@ -0,5 +1,19 @@

/*!
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as firestore from '@google-cloud/firestore';
import { FieldPath, Firestore } from '.';
import { DocumentReference } from './reference';
import { Timestamp } from './timestamp';
import { Precondition, SetOptions, UpdateData } from './types';
import { WriteResult } from './write-batch';

@@ -57,3 +71,3 @@ /**

*/
create<T>(documentRef: DocumentReference<T>, data: T): Promise<WriteResult>;
create<T>(documentRef: firestore.DocumentReference<T>, data: T): Promise<WriteResult>;
/**

@@ -69,4 +83,5 @@ * Delete a document from the database.

* document doesn't exist or was last updated at a different time.
* @returns {Promise<WriteResult>} A promise that resolves with the result of
* the write. Throws an error if the write fails.
* @returns {Promise<WriteResult>} A promise that resolves with a sentinel
* Timestamp indicating that the delete was successful. Throws an error if
* the write fails.
*

@@ -80,3 +95,3 @@ * @example

* .then(result => {
* console.log('Successfully deleted document at: ', result);
* console.log('Successfully deleted document');
* })

@@ -88,39 +103,6 @@ * .catch(err => {

*/
delete<T>(documentRef: DocumentReference<T>, precondition?: Precondition): Promise<WriteResult>;
delete<T>(documentRef: firestore.DocumentReference<T>, precondition?: firestore.Precondition): Promise<WriteResult>;
set<T>(documentRef: firestore.DocumentReference<T>, data: Partial<T>, options: firestore.SetOptions): Promise<WriteResult>;
set<T>(documentRef: firestore.DocumentReference<T>, data: T): Promise<WriteResult>;
/**
* Write to the document referred to by the provided
* [DocumentReference]{@link DocumentReference}. If the document does not
* exist yet, it will be created. If you pass [SetOptions]{@link SetOptions}.,
* the provided data can be merged into the existing document.
*
* @param {DocumentReference} documentRef A reference to the document to be
* set.
* @param {T} data The object to serialize as the document.
* @param {SetOptions=} options An object to configure the set behavior.
* @param {boolean=} options.merge - If true, set() merges the values
* specified in its data argument. Fields omitted from this set() call remain
* untouched.
* @param {Array.<string|FieldPath>=} options.mergeFields - If provided, set()
* only replaces the specified field paths. Any field path that is not
* specified is ignored and remains untouched.
* @returns {Promise<WriteResult>} A promise that resolves with the result of
* the write. Throws an error if the write fails.
*
*
* @example
* let bulkWriter = firestore.bulkWriter();
* let documentRef = firestore.collection('col').doc();
*
* bulkWriter
* .set(documentRef, {foo: 'bar'})
* .then(result => {
* console.log('Successfully executed write at: ', result);
* })
* .catch(err => {
* console.log('Write failed with: ', err);
* });
* });
*/
set<T>(documentRef: DocumentReference<T>, data: T, options?: SetOptions): Promise<WriteResult>;
/**
* Update fields of the document referred to by the provided

@@ -166,3 +148,3 @@ * [DocumentReference]{@link DocumentReference}. If the document doesn't yet

*/
update<T>(documentRef: DocumentReference, dataOrField: UpdateData | string | FieldPath, ...preconditionOrValues: Array<{
update<T>(documentRef: firestore.DocumentReference, dataOrField: firestore.UpdateData | string | FieldPath, ...preconditionOrValues: Array<{
lastUpdateTime?: Timestamp;

@@ -169,0 +151,0 @@ } | unknown | string | FieldPath>): Promise<WriteResult>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/*!
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const assert = require("assert");

@@ -65,3 +50,4 @@ const backoff_1 = require("./backoff");

class BulkCommitBatch {
constructor(writeBatch, maxBatchSize) {
constructor(firestore, writeBatch, maxBatchSize) {
this.firestore = firestore;
this.writeBatch = writeBatch;

@@ -97,3 +83,3 @@ this.maxBatchSize = maxBatchSize;

* Adds a `delete` operation to the WriteBatch. Returns a promise that
* resolves with the result of the delete.
* resolves with the sentinel value (Timestamp(0)) for the delete operation.
*/

@@ -208,2 +194,3 @@ delete(documentRef, precondition) {

this.closed = false;
this.firestore._incrementBulkWritersCount();
if (enableThrottling) {

@@ -257,4 +244,5 @@ this.rateLimiter = new rate_limiter_1.RateLimiter(STARTING_MAXIMUM_OPS_PER_SECOND, RATE_LIMITER_MULTIPLIER, RATE_LIMITER_MULTIPLIER_MILLIS);

* document doesn't exist or was last updated at a different time.
* @returns {Promise<WriteResult>} A promise that resolves with the result of
* the write. Throws an error if the write fails.
* @returns {Promise<WriteResult>} A promise that resolves with a sentinel
* Timestamp indicating that the delete was successful. Throws an error if
* the write fails.
*

@@ -268,3 +256,3 @@ * @example

* .then(result => {
* console.log('Successfully deleted document at: ', result);
* console.log('Successfully deleted document');
* })

@@ -427,2 +415,4 @@ * .catch(err => {

close() {
this.verifyNotClosed();
this.firestore._decrementBulkWritersCount();
const flushPromise = this.flush();

@@ -460,3 +450,3 @@ this.closed = true;

createNewBatch() {
const newBatch = new BulkCommitBatch(this.firestore.batch(), this.maxBatchSize);
const newBatch = new BulkCommitBatch(this.firestore, this.firestore.batch(), this.maxBatchSize);
if (this.batchQueue.length > 0) {

@@ -538,2 +528,3 @@ this.batchQueue[this.batchQueue.length - 1].markReadyToSend();

if (isRefInFlight) {
// eslint-disable-next-line no-console
console.warn('[BulkWriter]', `Duplicate write to document "${path}" detected.`, 'Writing to the same document multiple times will slow down BulkWriter. ' +

@@ -540,0 +531,0 @@ 'Write to unique documents in order to maximize throughput.');

@@ -155,6 +155,2 @@ "use strict";

};
case 'integerValue':
return {
integerValue: Number(fieldValue.integerValue),
};
case 'doubleValue':

@@ -161,0 +157,0 @@ return {

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

*/
import * as firestore from '@google-cloud/firestore';
import { QueryDocumentSnapshot } from './document';
import { DocumentData } from './types';
export declare type DocumentChangeType = 'added' | 'removed' | 'modified';

@@ -26,3 +26,3 @@ /**

*/
export declare class DocumentChange<T = DocumentData> {
export declare class DocumentChange<T = firestore.DocumentData> implements firestore.DocumentChange {
private readonly _type;

@@ -148,3 +148,3 @@ private readonly _document;

*/
isEqual(other: DocumentChange<T>): boolean;
isEqual(other: firestore.DocumentChange<T>): boolean;
}

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

*/
import * as firestore from '@google-cloud/firestore';
import { google } from '../protos/firestore_v1_proto_api';

@@ -23,3 +24,3 @@ import { FieldTransform } from './field-value';

import { Timestamp } from './timestamp';
import { ApiMapValue, DocumentData, UpdateMap } from './types';
import { ApiMapValue, UpdateMap } from './types';
import api = google.firestore.v1;

@@ -32,3 +33,3 @@ /**

*/
export declare class DocumentSnapshotBuilder<T = DocumentData> {
export declare class DocumentSnapshotBuilder<T = firestore.DocumentData> {
readonly ref: DocumentReference<T>;

@@ -67,3 +68,3 @@ /** The fields of the Firestore `Document` Protobuf backing this document. */

*/
export declare class DocumentSnapshot<T = DocumentData> {
export declare class DocumentSnapshot<T = firestore.DocumentData> implements firestore.DocumentSnapshot<T> {
readonly _fieldsProto?: ApiMapValue | undefined;

@@ -97,3 +98,3 @@ private _ref;

*/
static fromObject<U>(ref: DocumentReference<U>, obj: DocumentData): DocumentSnapshot<U>;
static fromObject<U>(ref: firestore.DocumentReference<U>, obj: firestore.DocumentData): DocumentSnapshot<U>;
/**

@@ -110,3 +111,3 @@ * Creates a DocumentSnapshot from an UpdateMap.

*/
static fromUpdateMap<U>(ref: DocumentReference<U>, data: UpdateMap): DocumentSnapshot<U>;
static fromUpdateMap<U>(ref: firestore.DocumentReference<U>, data: UpdateMap): DocumentSnapshot<U>;
/**

@@ -264,9 +265,14 @@ * True if the document exists.

/**
* Convert a document snapshot to the Firestore 'Document' Protobuf.
* Convert a document snapshot to the Firestore 'Write' proto.
*
* @private
* @returns The document in the format the API expects.
*/
toProto(): api.IWrite;
toWriteProto(): api.IWrite;
/**
* Convert a document snapshot to the Firestore 'Document' proto.
*
* @private
*/
toDocumentProto(): api.IDocument;
/**
* Returns true if the document's data and path in this `DocumentSnapshot` is

@@ -279,3 +285,3 @@ * equal to the provided value.

*/
isEqual(other: DocumentSnapshot<T>): boolean;
isEqual(other: firestore.DocumentSnapshot<T>): boolean;
}

@@ -297,3 +303,3 @@ /**

*/
export declare class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<T> {
export declare class QueryDocumentSnapshot<T = firestore.DocumentData> extends DocumentSnapshot<T> implements firestore.QueryDocumentSnapshot<T> {
/**

@@ -378,3 +384,3 @@ * The time the document was created.

*/
static fromFieldMask(fieldMask: Array<string | FieldPath>): DocumentMask;
static fromFieldMask(fieldMask: Array<string | firestore.FieldPath>): DocumentMask;
/**

@@ -387,3 +393,3 @@ * Creates a document mask with the field names of a document.

*/
static fromObject(data: DocumentData): DocumentMask;
static fromObject(data: firestore.DocumentData): DocumentMask;
/**

@@ -427,3 +433,3 @@ * Returns true if this document mask contains no fields.

*/
applyTo(data: DocumentData): DocumentData;
applyTo(data: firestore.DocumentData): firestore.DocumentData;
/**

@@ -446,3 +452,3 @@ * Converts a document mask to the Firestore 'DocumentMask' Proto.

*/
export declare class DocumentTransform<T = DocumentData> {
export declare class DocumentTransform<T = firestore.DocumentData> {
private readonly ref;

@@ -466,3 +472,3 @@ private readonly transforms;

*/
static fromObject<T>(ref: DocumentReference<T>, obj: DocumentData): DocumentTransform<T>;
static fromObject<T>(ref: firestore.DocumentReference<T>, obj: firestore.DocumentData): DocumentTransform<T>;
/**

@@ -476,3 +482,3 @@ * Generates a DocumentTransform from an Update Map.

*/
static fromUpdateMap<T>(ref: DocumentReference<T>, data: UpdateMap): DocumentTransform<T>;
static fromUpdateMap<T>(ref: firestore.DocumentReference<T>, data: UpdateMap): DocumentTransform<T>;
/**

@@ -525,3 +531,3 @@ * Whether this DocumentTransform contains any actionable transformations.

exists?: boolean;
lastUpdateTime?: Timestamp;
lastUpdateTime?: firestore.Timestamp;
});

@@ -528,0 +534,0 @@ /**

@@ -18,6 +18,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const deepEqual = require('deep-equal');
const deepEqual = require("fast-deep-equal");
const assert = require("assert");
const field_value_1 = require("./field-value");
const path_1 = require("./path");
const reference_1 = require("./reference");
const types_1 = require("./types");
const util_1 = require("./util");

@@ -282,3 +284,3 @@ /**

if (this._readTime === undefined) {
throw new Error(`Called 'readTime' on a local document`);
throw new Error("Called 'readTime' on a local document");
}

@@ -307,7 +309,15 @@ return this._readTime;

}
const obj = {};
for (const prop of Object.keys(fields)) {
obj[prop] = this._serializer.decodeValue(fields[prop]);
// We only want to use the converter and create a new QueryDocumentSnapshot
// if a converter has been provided.
if (this.ref._converter !== types_1.defaultConverter()) {
const untypedReference = new reference_1.DocumentReference(this.ref.firestore, this.ref._path);
return this.ref._converter.fromFirestore(new QueryDocumentSnapshot(untypedReference, this._fieldsProto, this.readTime, this.createTime, this.updateTime));
}
return this.ref._converter.fromFirestore(obj);
else {
const obj = {};
for (const prop of Object.keys(fields)) {
obj[prop] = this._serializer.decodeValue(fields[prop]);
}
return obj;
}
}

@@ -334,5 +344,4 @@ /**

// on end users.
// tslint:disable-next-line no-any
// eslint-disable-next-line @typescript-eslint/no-explicit-any
get(field) {
// tslint:disable-line no-any
path_1.validateFieldPath('field', field);

@@ -370,8 +379,7 @@ const protoField = this.protoField(field);

/**
* Convert a document snapshot to the Firestore 'Document' Protobuf.
* Convert a document snapshot to the Firestore 'Write' proto.
*
* @private
* @returns The document in the format the API expects.
*/
toProto() {
toWriteProto() {
return {

@@ -385,2 +393,15 @@ update: {

/**
* Convert a document snapshot to the Firestore 'Document' proto.
*
* @private
*/
toDocumentProto() {
return {
name: this._ref.formattedName,
createTime: this.createTime,
updateTime: this.updateTime,
fields: this._fieldsProto,
};
}
/**
* Returns true if the document's data and path in this `DocumentSnapshot` is

@@ -399,3 +420,3 @@ * equal to the provided value.

this._ref.isEqual(other._ref) &&
deepEqual(this._fieldsProto, other._fieldsProto, { strict: true })));
deepEqual(this._fieldsProto, other._fieldsProto)));
}

@@ -639,3 +660,3 @@ }

*/
const applyDocumentMask = (data) => {
const applyDocumentMask = data => {
const remainingPaths = this._sortedPaths.slice(0);

@@ -642,0 +663,0 @@ const processObject = (currentData, currentPath) => {

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

*/
import * as firestore from '@google-cloud/firestore';
import * as proto from '../protos/firestore_v1_proto_api';

@@ -27,3 +28,3 @@ import { FieldPath } from './path';

*/
export declare class FieldValue {
export declare class FieldValue implements firestore.FieldValue {
/**

@@ -173,3 +174,3 @@ * @hideconstructor

*/
isEqual(other: FieldValue): boolean;
isEqual(other: firestore.FieldValue): boolean;
}

@@ -235,3 +236,3 @@ /**

validate(): void;
toProto(serializer: Serializer, fieldPath: FieldPath): never;
toProto(): never;
}

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

Object.defineProperty(exports, "__esModule", { value: true });
const deepEqual = require('deep-equal');
const deepEqual = require("fast-deep-equal");
const serializer_1 = require("./serializer");

@@ -102,2 +102,3 @@ const validate_1 = require("./validate");

static increment(n) {
// eslint-disable-next-line prefer-rest-params
validate_1.validateMinNumberOfArguments('FieldValue.increment', arguments, 1);

@@ -130,3 +131,3 @@ return new NumericIncrementTransform(n);

static arrayUnion(...elements) {
validate_1.validateMinNumberOfArguments('FieldValue.arrayUnion', arguments, 1);
validate_1.validateMinNumberOfArguments('FieldValue.arrayUnion', elements, 1);
return new ArrayUnionTransform(elements);

@@ -157,3 +158,3 @@ }

static arrayRemove(...elements) {
validate_1.validateMinNumberOfArguments('FieldValue.arrayRemove', arguments, 1);
validate_1.validateMinNumberOfArguments('FieldValue.arrayRemove', elements, 1);
return new ArrayRemoveTransform(elements);

@@ -234,3 +235,3 @@ }

validate() { }
toProto(serializer, fieldPath) {
toProto() {
throw new Error('FieldValue.delete() should not be included in a FieldTransform');

@@ -371,3 +372,3 @@ }

(other instanceof ArrayUnionTransform &&
deepEqual(this.elements, other.elements, { strict: true })));
deepEqual(this.elements, other.elements)));
}

@@ -417,3 +418,3 @@ }

(other instanceof ArrayRemoveTransform &&
deepEqual(this.elements, other.elements, { strict: true })));
deepEqual(this.elements, other.elements)));
}

@@ -420,0 +421,0 @@ }

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

*/
import * as firestore from '@google-cloud/firestore';
import { google } from '../protos/firestore_v1_proto_api';

@@ -26,3 +27,3 @@ import { Serializable } from './serializer';

*/
export declare class GeoPoint implements Serializable {
export declare class GeoPoint implements Serializable, firestore.GeoPoint {
private readonly _latitude;

@@ -69,3 +70,3 @@ private readonly _longitude;

*/
isEqual(other: GeoPoint): boolean;
isEqual(other: firestore.GeoPoint): boolean;
/**

@@ -72,0 +73,0 @@ * Converts the GeoPoint to a google.type.LatLng proto.

@@ -17,7 +17,8 @@ /*!

/// <reference types="node" />
import * as firestore from '@google-cloud/firestore';
import { Duplex } from 'stream';
import { google } from '../protos/firestore_v1_proto_api';
import { BulkWriter } from './bulk-writer';
import { BundleBuilder } from './bundle';
import { DocumentSnapshot, QueryDocumentSnapshot } from './document';
import { FieldPath } from './path';
import { CollectionReference, Query } from './reference';

@@ -27,3 +28,3 @@ import { DocumentReference } from './reference';

import { Transaction } from './transaction';
import { BulkWriterOptions, FirestoreStreamingMethod, FirestoreUnaryMethod, ReadOptions, Settings } from './types';
import { BulkWriterOptions, FirestoreStreamingMethod, FirestoreUnaryMethod } from './types';
import { WriteBatch } from './write-batch';

@@ -41,3 +42,3 @@ import api = google.firestore.v1;

export { setLogFunction } from './logger';
export { BulkWriterOptions, FirestoreDataConverter, UpdateData, DocumentData, Settings, Precondition, SetOptions, } from './types';
export { BulkWriterOptions } from './types';
export { Status as GrpcStatus } from 'google-gax';

@@ -52,2 +53,48 @@ /**

/**
* Converter used by [withConverter()]{@link Query#withConverter} to transform
* user objects of type T into Firestore data.
*
* Using the converter allows you to specify generic type arguments when storing
* and retrieving objects from Firestore.
*
* @example
* class Post {
* constructor(readonly title: string, readonly author: string) {}
*
* toString(): string {
* return this.title + ', by ' + this.author;
* }
* }
*
* const postConverter = {
* toFirestore(post: Post): FirebaseFirestore.DocumentData {
* return {title: post.title, author: post.author};
* },
* fromFirestore(
* data: FirebaseFirestore.QueryDocumentSnapshot
* ): Post {
* const data = snapshot.data();
* return new Post(data.title, data.author);
* }
* };
*
* const postSnap = await Firestore()
* .collection('posts')
* .withConverter(postConverter)
* .doc().get();
* const post = postSnap.data();
* if (post !== undefined) {
* post.title; // string
* post.toString(); // Should be defined
* post.someNonExistentProperty; // TS error
* }
*
* @property {Function} toFirestore Called by the Firestore SDK to convert a
* custom model object of type T into a plain Javascript object (suitable for
* writing directly to the Firestore database).
* @property {Function} fromFirestore Called by the Firestore SDK to convert
* Firestore data into an object of type T.
* @typedef {Object} FirestoreDataConverter
*/
/**
* Update data (for use with [update]{@link DocumentReference#update})

@@ -144,3 +191,3 @@ * that contains paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that

*/
export declare class Firestore {
export declare class Firestore implements firestore.Firestore {
/**

@@ -156,3 +203,3 @@ * A client pool to distribute requests over multiple GAPIC clients in order

*/
_settings: Settings;
_settings: firestore.Settings;
/**

@@ -185,11 +232,16 @@ * Settings for the exponential backoff used by the streaming endpoints.

*
* The client can only be terminated when there are no registered listeners.
* The client can only be terminated when there are no pending writes or
* registered listeners.
* @private
*/
private registeredListenersCount;
/** @private */
_preferTransactions: boolean;
/** @private */
_lastSuccessfulRequest: number;
/**
* Number of pending operations on the client.
*
* The client can only be terminated when there are no pending writes or
* registered listeners.
* @private
*/
private bulkWritersCount;
/**
* @param {Object=} settings [Configuration object](#/docs).

@@ -217,3 +269,3 @@ * @param {string=} settings.projectId The project ID from the Google

* @param {boolean=} settings.ssl Whether to use SSL when connecting.
* @param {number=} settings.maxIdleChannels The maximum number of idle GRPC
* @param {number=} settings.maxIdleChannels The maximum number of idle GRPC
* channels to keep. A smaller number of idle channels reduces memory usage

@@ -223,4 +275,9 @@ * but increases request latency for clients with fluctuating request rates.

* Defaults to 1.
* @param {boolean=} settings.ignoreUndefinedProperties Whether to skip nested
* properties that are set to `undefined` during object serialization. If set
* to `true`, these properties are skipped and not written to Firestore. If
* set `false` or omitted, the SDK throws an exception when it encounters
* properties of type `undefined`.
*/
constructor(settings?: Settings);
constructor(settings?: firestore.Settings);
/**

@@ -236,3 +293,3 @@ * Specifies custom settings to be used to configure the `Firestore`

*/
settings(settings: Settings): void;
settings(settings: firestore.Settings): void;
private validateAndApplySettings;

@@ -386,2 +443,13 @@ /**

/**
* Creates a new `BundleBuilder` instance to package selected Firestore data into
* a bundle.
*
* @param bundleId. The id of the bundle. When loaded on clients, client SDKs use this id
* and the timestamp associated with the built bundle to tell if it has been loaded already.
* If not specified, a random identifier will be used.
*
* @private
*/
_bundle(name?: string): BundleBuilder;
/**
* Executes the given updateFunction and commits the changes applied within

@@ -466,3 +534,3 @@ * the transaction.

*/
getAll<T>(...documentRefsOrReadOptions: Array<DocumentReference<T> | ReadOptions>): Promise<Array<DocumentSnapshot<T>>>;
getAll<T>(...documentRefsOrReadOptions: Array<firestore.DocumentReference<T> | firestore.ReadOptions>): Promise<Array<DocumentSnapshot<T>>>;
/**

@@ -479,3 +547,3 @@ * Internal method to retrieve multiple documents from Firestore, optionally

*/
getAll_<T>(docRefs: Array<DocumentReference<T>>, fieldMask: FieldPath[] | null, requestTag: string, transactionId?: Uint8Array): Promise<Array<DocumentSnapshot<T>>>;
getAll_<T>(docRefs: Array<firestore.DocumentReference<T>>, fieldMask: firestore.FieldPath[] | null, requestTag: string, transactionId?: Uint8Array): Promise<Array<DocumentSnapshot<T>>>;
/**

@@ -498,2 +566,16 @@ * Registers a listener on this client, incrementing the listener count. This

/**
* Increments the number of open BulkWriter instances. This is used to verify
* that all pending operations are complete when terminate() is called.
*
* @private
*/
_incrementBulkWritersCount(): void;
/**
* Decrements the number of open BulkWriter instances. This is used to verify
* that all pending operations are complete when terminate() is called.
*
* @private
*/
_decrementBulkWritersCount(): void;
/**
* Terminates the Firestore client and closes all open streams.

@@ -500,0 +582,0 @@ *

@@ -20,6 +20,6 @@ "use strict";

const stream_1 = require("stream");
const through2 = require("through2");
const url_1 = require("url");
const backoff_1 = require("./backoff");
const bulk_writer_1 = require("./bulk-writer");
const bundle_1 = require("./bundle");
const convert_1 = require("./convert");

@@ -126,2 +126,48 @@ const document_1 = require("./document");

/**
* Converter used by [withConverter()]{@link Query#withConverter} to transform
* user objects of type T into Firestore data.
*
* Using the converter allows you to specify generic type arguments when storing
* and retrieving objects from Firestore.
*
* @example
* class Post {
* constructor(readonly title: string, readonly author: string) {}
*
* toString(): string {
* return this.title + ', by ' + this.author;
* }
* }
*
* const postConverter = {
* toFirestore(post: Post): FirebaseFirestore.DocumentData {
* return {title: post.title, author: post.author};
* },
* fromFirestore(
* data: FirebaseFirestore.QueryDocumentSnapshot
* ): Post {
* const data = snapshot.data();
* return new Post(data.title, data.author);
* }
* };
*
* const postSnap = await Firestore()
* .collection('posts')
* .withConverter(postConverter)
* .doc().get();
* const post = postSnap.data();
* if (post !== undefined) {
* post.title; // string
* post.toString(); // Should be defined
* post.someNonExistentProperty; // TS error
* }
*
* @property {Function} toFirestore Called by the Firestore SDK to convert a
* custom model object of type T into a plain Javascript object (suitable for
* writing directly to the Firestore database).
* @property {Function} fromFirestore Called by the Firestore SDK to convert
* Firestore data into an object of type T.
* @typedef {Object} FirestoreDataConverter
*/
/**
* Update data (for use with [update]{@link DocumentReference#update})

@@ -242,3 +288,3 @@ * that contains paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that

* @param {boolean=} settings.ssl Whether to use SSL when connecting.
* @param {number=} settings.maxIdleChannels The maximum number of idle GRPC
* @param {number=} settings.maxIdleChannels The maximum number of idle GRPC
* channels to keep. A smaller number of idle channels reduces memory usage

@@ -248,2 +294,7 @@ * but increases request latency for clients with fluctuating request rates.

* Defaults to 1.
* @param {boolean=} settings.ignoreUndefinedProperties Whether to skip nested
* properties that are set to `undefined` during object serialization. If set
* to `true`, these properties are skipped and not written to Firestore. If
* set `false` or omitted, the SDK throws an exception when it encounters
* properties of type `undefined`.
*/

@@ -278,8 +329,15 @@ constructor(settings) {

*
* The client can only be terminated when there are no registered listeners.
* The client can only be terminated when there are no pending writes or
* registered listeners.
* @private
*/
this.registeredListenersCount = 0;
/** @private */
this._lastSuccessfulRequest = 0;
/**
* Number of pending operations on the client.
*
* The client can only be terminated when there are no pending writes or
* registered listeners.
* @private
*/
this.bulkWritersCount = 0;
const libraryHeader = {

@@ -294,3 +352,8 @@ libName: 'gccl',

validate_1.validateHost('FIRESTORE_EMULATOR_HOST', process.env.FIRESTORE_EMULATOR_HOST);
const emulatorSettings = Object.assign(Object.assign(Object.assign({}, settings), libraryHeader), { host: process.env.FIRESTORE_EMULATOR_HOST, ssl: false });
const emulatorSettings = {
...settings,
...libraryHeader,
host: process.env.FIRESTORE_EMULATOR_HOST,
ssl: false,
};
// If FIRESTORE_EMULATOR_HOST is set, we unset `servicePath` and `apiEndpoint` to

@@ -303,3 +366,3 @@ // ensure that only one endpoint setting is provided.

else {
this.validateAndApplySettings(Object.assign(Object.assign({}, settings), libraryHeader));
this.validateAndApplySettings({ ...settings, ...libraryHeader });
}

@@ -312,14 +375,2 @@ const retryConfig = serviceConfig.retry_params.default;

};
// GCF currently tears down idle connections after two minutes. Requests
// that are issued after this period may fail. On GCF, we therefore issue
// these requests as part of a transaction so that we can safely retry until
// the network link is reestablished.
//
// The environment variable FUNCTION_TRIGGER_TYPE is used to detect the GCF
// environment.
this._preferTransactions = process.env.FUNCTION_TRIGGER_TYPE !== undefined;
this._lastSuccessfulRequest = 0;
if (this._preferTransactions) {
logger_1.logger('Firestore', null, 'Detected GCF environment');
}
const maxIdleChannels = this._settings.maxIdleChannels === undefined

@@ -330,7 +381,11 @@ ? DEFAULT_MAX_IDLE_CHANNELS

/* clientFactory= */ () => {
var _a;
let client;
if (this._settings.ssl === false) {
const grpc = require('@grpc/grpc-js');
const sslCreds = grpc.credentials.createInsecure();
client = new module.exports.v1(Object.assign({ sslCreds }, this._settings));
const grpcModule = (_a = this._settings.grpc) !== null && _a !== void 0 ? _a : google_gax_1.grpc;
const sslCreds = grpcModule.credentials.createInsecure();
client = new module.exports.v1({
sslCreds,
...this._settings,
});
}

@@ -364,3 +419,3 @@ else {

}
const mergedSettings = Object.assign(Object.assign({}, this._settings), settings);
const mergedSettings = { ...this._settings, ...settings };
this.validateAndApplySettings(mergedSettings);

@@ -569,3 +624,3 @@ this._settingsFrozen = true;

else {
throw new Error(`Unsupported encoding format. Expected "json" or "protobufJS", ` +
throw new Error('Unsupported encoding format. Expected "json" or "protobufJS", ' +
`but was "${encoding}".`);

@@ -594,2 +649,15 @@ }

/**
* Creates a new `BundleBuilder` instance to package selected Firestore data into
* a bundle.
*
* @param bundleId. The id of the bundle. When loaded on clients, client SDKs use this id
* and the timestamp associated with the built bundle to tell if it has been loaded already.
* If not specified, a random identifier will be used.
*
* @private
*/
_bundle(name) {
return new bundle_1.BundleBuilder(name || util_1.autoId());
}
/**
* Executes the given updateFunction and commits the changes applied within

@@ -691,3 +759,3 @@ * the transaction.

getAll(...documentRefsOrReadOptions) {
validate_1.validateMinNumberOfArguments('Firestore.getAll', arguments, 1);
validate_1.validateMinNumberOfArguments('Firestore.getAll', documentRefsOrReadOptions, 1);
const { documents, fieldMask } = transaction_1.parseGetAllArguments(documentRefsOrReadOptions);

@@ -803,2 +871,20 @@ const tag = util_1.requestTag();

/**
* Increments the number of open BulkWriter instances. This is used to verify
* that all pending operations are complete when terminate() is called.
*
* @private
*/
_incrementBulkWritersCount() {
this.bulkWritersCount += 1;
}
/**
* Decrements the number of open BulkWriter instances. This is used to verify
* that all pending operations are complete when terminate() is called.
*
* @private
*/
_decrementBulkWritersCount() {
this.bulkWritersCount -= 1;
}
/**
* Terminates the Firestore client and closes all open streams.

@@ -809,4 +895,7 @@ *

terminate() {
if (this.registeredListenersCount > 0) {
return Promise.reject('All onSnapshot() listeners must be unsubscribed before terminating the client.');
if (this.registeredListenersCount > 0 || this.bulkWritersCount > 0) {
return Promise.reject('All onSnapshot() listeners must be unsubscribed, and all BulkWriter ' +
'instances must be closed before terminating the client. ' +
`There are ${this.registeredListenersCount} active listeners and ` +
`${this.bulkWritersCount} open BulkWriter instances.`);
}

@@ -834,3 +923,6 @@ return this._clientPool.terminate();

// precedence).
this._settings.customHeaders = Object.assign({ Authorization: 'Bearer owner' }, this._settings.customHeaders);
this._settings.customHeaders = {
Authorization: 'Bearer owner',
...this._settings.customHeaders,
};
}

@@ -855,3 +947,6 @@ if (this._projectId === undefined) {

otherArgs: {
headers: Object.assign({ [CLOUD_RESOURCE_HEADER]: this.formattedName }, this._settings.customHeaders),
headers: {
[CLOUD_RESOURCE_HEADER]: this.formattedName,
...this._settings.customHeaders,
},
},

@@ -896,5 +991,3 @@ };

await backoff.backoffAndWait();
const result = await func();
this._lastSuccessfulRequest = new Date().getTime();
return result;
return await func();
}

@@ -1006,3 +1099,2 @@ catch (err) {

logger_1.logger('Firestore.request', requestTag, 'Received response: %j', result);
this._lastSuccessfulRequest = new Date().getTime();
return result;

@@ -1041,5 +1133,8 @@ }

: gapicClient[methodName](request, callOptions);
const logStream = through2.obj(function (chunk, enc, callback) {
logger_1.logger('Firestore.requestStream', requestTag, 'Received response: %j', chunk);
callback();
const logStream = new stream_1.Transform({
objectMode: true,
transform: (chunk, encoding, callback) => {
logger_1.logger('Firestore.requestStream', requestTag, 'Received response: %j', chunk);
callback();
},
});

@@ -1046,0 +1141,0 @@ stream.pipe(logStream);

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

*/
import * as firestore from '@google-cloud/firestore';
import { google } from '../protos/firestore_v1_proto_api';

@@ -235,10 +236,7 @@ import api = google.firestore.v1;

* Convenience method to match the ResourcePath API. This method always
* returns the current instance. The arguments is ignored.
* returns the current instance.
*
* @param projectIdIfMissing The project ID of the current Firestore project.
* The project ID is only used if it's not provided as part of this
* ResourcePath.
* @private
*/
toQualifiedResourcePath(projectIdIfMissing: string): QualifiedResourcePath;
toQualifiedResourcePath(): QualifiedResourcePath;
/**

@@ -273,3 +271,3 @@ * Compare the current path against another ResourcePath object.

*/
export declare class FieldPath extends Path<FieldPath> {
export declare class FieldPath extends Path<FieldPath> implements firestore.FieldPath {
/**

@@ -313,3 +311,3 @@ * A special sentinel value to refer to the ID of a document.

*/
static fromArgument(fieldPath: string | FieldPath): FieldPath;
static fromArgument(fieldPath: string | firestore.FieldPath): FieldPath;
/**

@@ -366,3 +364,3 @@ * String representation of a FieldPath as expected by the API.

*/
export declare function validateFieldPath(arg: string | number, fieldPath: unknown): void;
export declare function validateFieldPath(arg: string | number, fieldPath: unknown): asserts fieldPath is string | FieldPath;
export {};

@@ -350,10 +350,7 @@ "use strict";

* Convenience method to match the ResourcePath API. This method always
* returns the current instance. The arguments is ignored.
* returns the current instance.
*
* @param projectIdIfMissing The project ID of the current Firestore project.
* The project ID is only used if it's not provided as part of this
* ResourcePath.
* @private
*/
toQualifiedResourcePath(projectIdIfMissing) {
toQualifiedResourcePath() {
return this;

@@ -360,0 +357,0 @@ }

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

*/
export declare const CLIENT_TERMINATED_ERROR_MSG = "The client has already been terminated";
/**

@@ -18,0 +19,0 @@ * An auto-resizing pool that distributes concurrent operations over multiple

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

const util_1 = require("./util");
exports.CLIENT_TERMINATED_ERROR_MSG = 'The client has already been terminated';
/**

@@ -123,3 +124,3 @@ * An auto-resizing pool that distributes concurrent operations over multiple

let idleCapacityCount = 0;
for (const [_, count] of this.activeClients) {
for (const [, count] of this.activeClients) {
idleCapacityCount += this.concurrentOperationLimit - count;

@@ -164,3 +165,3 @@ }

if (this.terminated) {
return Promise.reject(new Error('The client has already been terminated'));
return Promise.reject(new Error(exports.CLIENT_TERMINATED_ERROR_MSG));
}

@@ -186,3 +187,3 @@ const client = this.acquire(requestTag);

}
for (const [client, _requestCount] of this.activeClients) {
for (const [client] of this.activeClients) {
this.activeClients.delete(client);

@@ -189,0 +190,0 @@ await this.clientDestructor(client);

@@ -35,3 +35,3 @@ /**

*
* @param requestTimeMillis The date used to calculate the number of available
* @param requestTimeMillis The time used to calculate the number of available
* tokens. Used for testing the limiter.

@@ -47,3 +47,3 @@ * @private

*
* @param requestTimeMillis The date used to calculate the number of available
* @param requestTimeMillis The time used to calculate the number of available
* tokens. Used for testing the limiter.

@@ -57,3 +57,3 @@ * @private

*
* @param requestTimeMillis The date used to calculate the number of available
* @param requestTimeMillis The time used to calculate the number of available
* tokens. Used for testing the limiter.

@@ -60,0 +60,0 @@ * @private

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

*
* @param requestTimeMillis The date used to calculate the number of available
* @param requestTimeMillis The time used to calculate the number of available
* tokens. Used for testing the limiter.

@@ -73,3 +73,3 @@ * @private

*
* @param requestTimeMillis The date used to calculate the number of available
* @param requestTimeMillis The time used to calculate the number of available
* tokens. Used for testing the limiter.

@@ -94,7 +94,7 @@ * @private

*
* @param requestTimeMillis The date used to calculate the number of available
* @param requestTimeMillis The time used to calculate the number of available
* tokens. Used for testing the limiter.
* @private
*/
refillTokens(requestTimeMillis = Date.now()) {
refillTokens(requestTimeMillis) {
if (requestTimeMillis >= this.lastRefillTimeMillis) {

@@ -101,0 +101,0 @@ const elapsedTime = requestTimeMillis - this.lastRefillTimeMillis;

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

/// <reference types="node" />
import * as proto from '../protos/firestore_v1_proto_api';
import * as firestore from '@google-cloud/firestore';
import * as protos from '../protos/firestore_v1_proto_api';
import { DocumentSnapshot, QueryDocumentSnapshot } from './document';

@@ -25,5 +26,4 @@ import { DocumentChange } from './document-change';

import { Timestamp } from './timestamp';
import { DocumentData, FirestoreDataConverter, OrderByDirection, Precondition, SetOptions, UpdateData, WhereFilterOp } from './types';
import { WriteResult } from './write-batch';
import api = proto.google.firestore.v1;
import api = protos.google.firestore.v1;
/**

@@ -57,6 +57,6 @@ * onSnapshot() callback that receives a QuerySnapshot.

*/
export declare class DocumentReference<T = DocumentData> implements Serializable {
export declare class DocumentReference<T = firestore.DocumentData> implements Serializable, firestore.DocumentReference<T> {
private readonly _firestore;
readonly _path: ResourcePath;
readonly _converter: FirestoreDataConverter<T>;
readonly _converter: firestore.FirestoreDataConverter<T>;
/**

@@ -68,3 +68,3 @@ * @hideconstructor

*/
constructor(_firestore: Firestore, _path: ResourcePath, _converter?: FirestoreDataConverter<T>);
constructor(_firestore: Firestore, _path: ResourcePath, _converter?: firestore.FirestoreDataConverter<T>);
/**

@@ -188,3 +188,3 @@ * The string representation of the DocumentReference's location.

*/
listCollections(): Promise<Array<CollectionReference<DocumentData>>>;
listCollections(): Promise<Array<CollectionReference<firestore.DocumentData>>>;
/**

@@ -230,28 +230,6 @@ * Create a document with the provided object values. This will fail the write

*/
delete(precondition?: Precondition): Promise<WriteResult>;
delete(precondition?: firestore.Precondition): Promise<WriteResult>;
set(data: Partial<T>, options: firestore.SetOptions): Promise<WriteResult>;
set(data: T): Promise<WriteResult>;
/**
* Writes to the document referred to by this DocumentReference. If the
* document does not yet exist, it will be created. If you pass
* [SetOptions]{@link SetOptions}, the provided data can be merged into an
* existing document.
*
* @param {T} data A map of the fields and values for the document.
* @param {SetOptions=} options An object to configure the set behavior.
* @param {boolean=} options.merge If true, set() merges the values specified
* in its data argument. Fields omitted from this set() call remain untouched.
* @param {Array.<string|FieldPath>=} options.mergeFields If provided,
* set() only replaces the specified field paths. Any field path that is not
* specified is ignored and remains untouched.
* @returns {Promise.<WriteResult>} A Promise that resolves with the
* write time of this set.
*
* @example
* let documentRef = firestore.doc('col/doc');
*
* documentRef.set({foo: 'bar'}).then(res => {
* console.log(`Document written at ${res.updateTime}`);
* });
*/
set(data: T, options?: SetOptions): Promise<WriteResult>;
/**
* Updates fields in the document referred to by this DocumentReference.

@@ -285,3 +263,3 @@ * If the document doesn't yet exist, the update fails and the returned

*/
update(dataOrField: UpdateData | string | FieldPath, ...preconditionOrValues: Array<unknown | string | FieldPath | Precondition>): Promise<WriteResult>;
update(dataOrField: firestore.UpdateData | string | firestore.FieldPath, ...preconditionOrValues: Array<unknown | string | firestore.FieldPath | firestore.Precondition>): Promise<WriteResult>;
/**

@@ -313,3 +291,3 @@ * Attaches a listener for DocumentSnapshot events.

*/
onSnapshot(onNext: (snapshot: DocumentSnapshot<T>) => void, onError?: (error: Error) => void): () => void;
onSnapshot(onNext: (snapshot: firestore.DocumentSnapshot<T>) => void, onError?: (error: Error) => void): () => void;
/**

@@ -322,3 +300,3 @@ * Returns true if this `DocumentReference` is equal to the provided value.

*/
isEqual(other: DocumentReference<T>): boolean;
isEqual(other: firestore.DocumentReference<T>): boolean;
/**

@@ -331,7 +309,6 @@ * Converts this DocumentReference to the Firestore Proto representation.

/**
* Applies a custom data converter to this DocumentReference, allowing you
* to use your own custom model objects with Firestore. When you call
* set(), get(), etc. on the returned DocumentReference instance, the
* provided converter will convert between Firestore data and your custom
* type U.
* Applies a custom data converter to this DocumentReference, allowing you to
* use your own custom model objects with Firestore. When you call set(),
* get(), etc. on the returned DocumentReference instance, the provided
* converter will convert between Firestore data and your custom type U.
*

@@ -355,4 +332,5 @@ * Using the converter allows you to specify generic type arguments when

* fromFirestore(
* data: FirebaseFirestore.DocumentData
* snapshot: FirebaseFirestore.QueryDocumentSnapshot
* ): Post {
* const data = snapshot.data();
* return new Post(data.title, data.author);

@@ -373,6 +351,7 @@ * }

*
* @param converter Converts objects to and from Firestore.
* @param {FirestoreDataConverter} converter Converts objects to and from
* Firestore.
* @return A DocumentReference<U> that uses the provided converter.
*/
withConverter<U>(converter: FirestoreDataConverter<U>): DocumentReference<U>;
withConverter<U>(converter: firestore.FirestoreDataConverter<U>): DocumentReference<U>;
}

@@ -445,3 +424,3 @@ /**

*/
export declare class QuerySnapshot<T = DocumentData> {
export declare class QuerySnapshot<T = firestore.DocumentData> implements firestore.QuerySnapshot<T> {
private readonly _query;

@@ -588,3 +567,3 @@ private readonly _readTime;

*/
forEach(callback: (result: QueryDocumentSnapshot<T>) => void, thisArg?: unknown): void;
forEach(callback: (result: firestore.QueryDocumentSnapshot<T>) => void, thisArg?: unknown): void;
/**

@@ -598,3 +577,3 @@ * Returns true if the document data in this `QuerySnapshot` is equal to the

*/
isEqual(other: QuerySnapshot<T>): boolean;
isEqual(other: firestore.QuerySnapshot<T>): boolean;
}

@@ -623,3 +602,3 @@ /** Internal representation of a query cursor before serialization. */

readonly collectionId: string;
readonly converter: FirestoreDataConverter<T>;
readonly converter: firestore.FirestoreDataConverter<T>;
readonly allDescendants: boolean;

@@ -634,3 +613,3 @@ readonly fieldFilters: FieldFilter[];

readonly projection?: api.StructuredQuery.IProjection | undefined;
constructor(parentPath: ResourcePath, collectionId: string, converter: FirestoreDataConverter<T>, allDescendants: boolean, fieldFilters: FieldFilter[], fieldOrders: FieldOrder[], startAt?: QueryCursor | undefined, endAt?: QueryCursor | undefined, limit?: number | undefined, limitType?: LimitType | undefined, offset?: number | undefined, projection?: api.StructuredQuery.IProjection | undefined);
constructor(parentPath: ResourcePath, collectionId: string, converter: firestore.FirestoreDataConverter<T>, allDescendants: boolean, fieldFilters: FieldFilter[], fieldOrders: FieldOrder[], startAt?: QueryCursor | undefined, endAt?: QueryCursor | undefined, limit?: number | undefined, limitType?: LimitType | undefined, offset?: number | undefined, projection?: api.StructuredQuery.IProjection | undefined);
/**

@@ -640,3 +619,3 @@ * Returns query options for a collection group query.

*/
static forCollectionGroupQuery<T>(collectionId: string, converter?: FirestoreDataConverter<T>): QueryOptions<T>;
static forCollectionGroupQuery<T>(collectionId: string, converter?: firestore.FirestoreDataConverter<T>): QueryOptions<T>;
/**

@@ -646,3 +625,3 @@ * Returns query options for a single-collection query.

*/
static forCollectionQuery<T>(collectionRef: ResourcePath, converter?: FirestoreDataConverter<T>): QueryOptions<T>;
static forCollectionQuery<T>(collectionRef: ResourcePath, converter?: firestore.FirestoreDataConverter<T>): QueryOptions<T>;
/**

@@ -653,5 +632,5 @@ * Returns the union of the current and the provided options.

with(settings: Partial<Omit<QueryOptions<T>, 'converter'>>): QueryOptions<T>;
withConverter<U>(converter: FirestoreDataConverter<U>): QueryOptions<U>;
withConverter<U>(converter: firestore.FirestoreDataConverter<U>): QueryOptions<U>;
hasFieldOrders(): boolean;
isEqual(other: QueryOptions<T>): any;
isEqual(other: QueryOptions<T>): boolean;
}

@@ -664,3 +643,3 @@ /**

*/
export declare class Query<T = DocumentData> {
export declare class Query<T = firestore.DocumentData> implements firestore.Query<T> {
private readonly _firestore;

@@ -741,3 +720,3 @@ protected readonly _queryOptions: QueryOptions<T>;

*/
where(fieldPath: string | FieldPath, opStr: WhereFilterOp, value: unknown): Query<T>;
where(fieldPath: string | firestore.FieldPath, opStr: firestore.WhereFilterOp, value: unknown): Query<T>;
/**

@@ -791,3 +770,3 @@ * Creates and returns a new [Query]{@link Query} instance that applies a

*/
orderBy(fieldPath: string | FieldPath, directionStr?: OrderByDirection): Query<T>;
orderBy(fieldPath: string | firestore.FieldPath, directionStr?: firestore.OrderByDirection): Query<T>;
/**

@@ -861,3 +840,3 @@ * Creates and returns a new [Query]{@link Query} that only returns the

*/
isEqual(other: Query<T>): boolean;
isEqual(other: firestore.Query<T>): boolean;
/**

@@ -917,3 +896,3 @@ * Computes the backend ordering semantics for DocumentSnapshot cursors.

*/
startAt(...fieldValuesOrDocumentSnapshot: Array<DocumentSnapshot<unknown> | unknown>): Query<T>;
startAt(...fieldValuesOrDocumentSnapshot: Array<firestore.DocumentSnapshot<unknown> | unknown>): Query<T>;
/**

@@ -939,3 +918,3 @@ * Creates and returns a new [Query]{@link Query} that starts after the

*/
startAfter(...fieldValuesOrDocumentSnapshot: Array<DocumentSnapshot<unknown> | unknown>): Query<T>;
startAfter(...fieldValuesOrDocumentSnapshot: Array<firestore.DocumentSnapshot<unknown> | unknown>): Query<T>;
/**

@@ -960,3 +939,3 @@ * Creates and returns a new [Query]{@link Query} that ends before the set of

*/
endBefore(...fieldValuesOrDocumentSnapshot: Array<DocumentSnapshot<unknown> | unknown>): Query<T>;
endBefore(...fieldValuesOrDocumentSnapshot: Array<firestore.DocumentSnapshot<unknown> | unknown>): Query<T>;
/**

@@ -981,3 +960,3 @@ * Creates and returns a new [Query]{@link Query} that ends at the provided

*/
endAt(...fieldValuesOrDocumentSnapshot: Array<DocumentSnapshot<unknown> | unknown>): Query<T>;
endAt(...fieldValuesOrDocumentSnapshot: Array<firestore.DocumentSnapshot<unknown> | unknown>): Query<T>;
/**

@@ -1045,2 +1024,7 @@ * Executes the query and returns the results as a

/**
* Converts current Query to an IBundledQuery.
*/
_toBundledQuery(): protos.firestore.IBundledQuery;
private toStructuredQuery;
/**
* Internal streaming method that accepts an optional transaction ID.

@@ -1076,3 +1060,3 @@ *

*/
onSnapshot(onNext: (snapshot: QuerySnapshot<T>) => void, onError?: (error: Error) => void): () => void;
onSnapshot(onNext: (snapshot: firestore.QuerySnapshot<T>) => void, onError?: (error: Error) => void): () => void;
/**

@@ -1108,4 +1092,5 @@ * Returns a function that can be used to sort QueryDocumentSnapshots

* fromFirestore(
* data: FirebaseFirestore.DocumentData
* snapshot: FirebaseFirestore.QueryDocumentSnapshot
* ): Post {
* const data = snapshot.data();
* return new Post(data.title, data.author);

@@ -1126,6 +1111,7 @@ * }

*
* @param converter Converts objects to and from Firestore.
* @param {FirestoreDataConverter} converter Converts objects to and from
* Firestore.
* @return A Query<U> that uses the provided converter.
*/
withConverter<U>(converter: FirestoreDataConverter<U>): Query<U>;
withConverter<U>(converter: firestore.FirestoreDataConverter<U>): Query<U>;
}

@@ -1140,3 +1126,3 @@ /**

*/
export declare class CollectionReference<T = DocumentData> extends Query<T> {
export declare class CollectionReference<T = firestore.DocumentData> extends Query<T> implements firestore.CollectionReference<T> {
/**

@@ -1148,3 +1134,3 @@ * @hideconstructor

*/
constructor(firestore: Firestore, path: ResourcePath, converter?: FirestoreDataConverter<T>);
constructor(firestore: Firestore, path: ResourcePath, converter?: firestore.FirestoreDataConverter<T>);
/**

@@ -1180,3 +1166,3 @@ * Returns a resource path for this collection.

*/
get parent(): DocumentReference<DocumentData> | null;
get parent(): DocumentReference<firestore.DocumentData> | null;
/**

@@ -1249,7 +1235,7 @@ * A string representing the path of the referenced collection (relative

*/
isEqual(other: CollectionReference<T>): boolean;
isEqual(other: firestore.CollectionReference<T>): boolean;
/**
* Applies a custom data converter to this CollectionReference, allowing you
* to use your own custom model objects with Firestore. When you call add()
* on the returned CollectionReference instance, the provided converter will
* to use your own custom model objects with Firestore. When you call add() on
* the returned CollectionReference instance, the provided converter will
* convert between Firestore data and your custom type U.

@@ -1274,4 +1260,5 @@ *

* fromFirestore(
* data: FirebaseFirestore.DocumentData
* snapshot: FirebaseFirestore.QueryDocumentSnapshot
* ): Post {
* const data = snapshot.data();
* return new Post(data.title, data.author);

@@ -1292,6 +1279,7 @@ * }

*
* @param converter Converts objects to and from Firestore.
* @param {FirestoreDataConverter} converter Converts objects to and from
* Firestore.
* @return A CollectionReference<U> that uses the provided converter.
*/
withConverter<U>(converter: FirestoreDataConverter<U>): CollectionReference<U>;
withConverter<U>(converter: firestore.FirestoreDataConverter<U>): CollectionReference<U>;
}

@@ -1308,3 +1296,3 @@ /**

*/
export declare function validateQueryOrder(arg: string, op: unknown): OrderByDirection | undefined;
export declare function validateQueryOrder(arg: string, op: unknown): firestore.OrderByDirection | undefined;
/**

@@ -1321,3 +1309,3 @@ * Validates the input string as a field comparison operator.

*/
export declare function validateQueryOperator(arg: string | number, op: unknown, fieldValue: unknown): WhereFilterOp;
export declare function validateQueryOperator(arg: string | number, op: unknown, fieldValue: unknown): firestore.WhereFilterOp;
/**

@@ -1329,4 +1317,5 @@ * Validates that 'value' is a DocumentReference.

* @param value The argument to validate.
* @return the DocumentReference if valid
*/
export declare function validateDocumentReference(arg: string | number, value: unknown): void;
export declare function validateDocumentReference(arg: string | number, value: unknown): DocumentReference;
export {};

@@ -16,6 +16,7 @@ /*!

*/
import { DocumentData } from '@google-cloud/firestore';
import * as proto from '../protos/firestore_v1_proto_api';
import { Firestore } from './index';
import { FieldPath } from './path';
import { ApiMapValue, DocumentData, ValidationOptions } from './types';
import { ApiMapValue, ValidationOptions } from './types';
import api = proto.google.firestore.v1;

@@ -39,2 +40,3 @@ /**

private createReference;
private createInteger;
constructor(firestore: Firestore);

@@ -41,0 +43,0 @@ /**

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

const field_value_1 = require("./field-value");
const field_value_2 = require("./field-value");
const geo_point_1 = require("./geo-point");

@@ -46,2 +45,3 @@ const index_1 = require("./index");

this.createReference = path => firestore.doc(path);
this.createInteger = n => firestore._settings.useBigInt ? BigInt(n) : Number(n);
this.allowUndefined = !!firestore._settings.ignoreUndefinedProperties;

@@ -99,2 +99,7 @@ }

}
if (typeof val === 'bigint') {
return {
integerValue: val.toString(),
};
}
if (val instanceof Date) {

@@ -185,10 +190,9 @@ const timestamp = timestamp_1.Timestamp.fromDate(val);

case 'integerValue': {
return Number(proto.integerValue);
return this.createInteger(proto.integerValue);
}
case 'doubleValue': {
return Number(proto.doubleValue);
return proto.doubleValue;
}
case 'timestampValue': {
const timestamp = timestamp_1.Timestamp.fromProto(proto.timestampValue);
return timestamp;
return timestamp_1.Timestamp.fromProto(proto.timestampValue);
}

@@ -252,3 +256,2 @@ case 'referenceValue': {

}
options = options || {};
level = level || 0;

@@ -277,3 +280,3 @@ inArray = inArray || false;

}
else if (value instanceof field_value_2.DeleteTransform) {
else if (value instanceof field_value_1.DeleteTransform) {
if (inArray) {

@@ -330,5 +333,4 @@ throw new Error(`${validate_1.invalidArgumentMessage(arg, desc)} ${value.methodName}() cannot be used inside of an array${fieldPathMessage}.`);

value.constructor.name === 'Moment' &&
// tslint:disable-next-line:no-any
typeof value.toDate === 'function');
}
//# sourceMappingURL=serializer.js.map

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

*/
import * as firestore from '@google-cloud/firestore';
import { google } from '../protos/firestore_v1_proto_api';

@@ -30,3 +31,3 @@ import api = google.firestore.v1;

*/
export declare class Timestamp {
export declare class Timestamp implements firestore.Timestamp {
private readonly _seconds;

@@ -172,3 +173,3 @@ private readonly _nanoseconds;

*/
isEqual(other: Timestamp): boolean;
isEqual(other: firestore.Timestamp): boolean;
/**

@@ -175,0 +176,0 @@ * Generates the Protobuf `Timestamp` object for this timestamp.

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

static fromProto(timestamp) {
return new Timestamp(Number(timestamp.seconds || 0), Number(timestamp.nanos || 0));
return new Timestamp(Number(timestamp.seconds || 0), timestamp.nanos || 0);
}

@@ -138,0 +138,0 @@ /**

@@ -16,7 +16,7 @@ /*!

*/
import { DocumentSnapshot, Precondition } from './document';
import * as firestore from '@google-cloud/firestore';
import { DocumentSnapshot } from './document';
import { Firestore } from './index';
import { FieldPath } from './path';
import { DocumentReference, Query, QuerySnapshot } from './reference';
import { Precondition as PublicPrecondition, ReadOptions, SetOptions, UpdateData } from './types';
/**

@@ -31,3 +31,3 @@ * A reference to a transaction.

*/
export declare class Transaction {
export declare class Transaction implements firestore.Transaction {
private _firestore;

@@ -88,3 +88,3 @@ private _writeBatch;

*/
getAll<T>(...documentRefsOrReadOptions: Array<DocumentReference<T> | ReadOptions>): Promise<Array<DocumentSnapshot<T>>>;
getAll<T>(...documentRefsOrReadOptions: Array<firestore.DocumentReference<T> | firestore.ReadOptions>): Promise<Array<DocumentSnapshot<T>>>;
/**

@@ -111,32 +111,6 @@ * Create the document referred to by the provided

*/
create<T>(documentRef: DocumentReference<T>, data: T): Transaction;
create<T>(documentRef: firestore.DocumentReference<T>, data: T): Transaction;
set<T>(documentRef: firestore.DocumentReference<T>, data: Partial<T>, options: firestore.SetOptions): Transaction;
set<T>(documentRef: firestore.DocumentReference<T>, data: T): Transaction;
/**
* Writes to the document referred to by the provided
* [DocumentReference]{@link DocumentReference}. If the document
* does not exist yet, it will be created. If you pass
* [SetOptions]{@link SetOptions}, the provided data can be merged into the
* existing document.
*
* @param {DocumentReference} documentRef A reference to the document to be
* set.
* @param {T} data The object to serialize as the document.
* @param {SetOptions=} options An object to configure the set behavior.
* @param {boolean=} options.merge - If true, set() merges the values
* specified in its data argument. Fields omitted from this set() call
* remain untouched.
* @param {Array.<string|FieldPath>=} options.mergeFields - If provided,
* set() only replaces the specified field paths. Any field path that is not
* specified is ignored and remains untouched.
* @returns {Transaction} This Transaction instance. Used for
* chaining method calls.
*
* @example
* firestore.runTransaction(transaction => {
* let documentRef = firestore.doc('col/doc');
* transaction.set(documentRef, { foo: 'bar' });
* return Promise.resolve();
* });
*/
set<T>(documentRef: DocumentReference<T>, data: T, options?: SetOptions): Transaction;
/**
* Updates fields in the document referred to by the provided

@@ -179,3 +153,3 @@ * [DocumentReference]{@link DocumentReference}. The update will

*/
update<T>(documentRef: DocumentReference<T>, dataOrField: UpdateData | string | FieldPath, ...preconditionOrValues: Array<Precondition | unknown | string | FieldPath>): Transaction;
update<T>(documentRef: firestore.DocumentReference<T>, dataOrField: firestore.UpdateData | string | firestore.FieldPath, ...preconditionOrValues: Array<firestore.Precondition | unknown | string | firestore.FieldPath>): Transaction;
/**

@@ -202,3 +176,3 @@ * Deletes the document referred to by the provided [DocumentReference]

*/
delete<T>(documentRef: DocumentReference<T>, precondition?: PublicPrecondition): this;
delete<T>(documentRef: DocumentReference<T>, precondition?: firestore.Precondition): this;
/**

@@ -249,5 +223,5 @@ * Starts a transaction and obtains the transaction id from the server.

*/
export declare function parseGetAllArguments<T>(documentRefsOrReadOptions: Array<DocumentReference<T> | ReadOptions>): {
export declare function parseGetAllArguments<T>(documentRefsOrReadOptions: Array<firestore.DocumentReference<T> | firestore.ReadOptions>): {
documents: Array<DocumentReference<T>>;
fieldMask: FieldPath[] | null;
};

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

}
validate_1.validateMinNumberOfArguments('Transaction.getAll', arguments, 1);
validate_1.validateMinNumberOfArguments('Transaction.getAll', documentRefsOrReadOptions, 1);
const { documents, fieldMask } = parseGetAllArguments(documentRefsOrReadOptions);

@@ -160,3 +160,3 @@ return this._firestore.getAll_(documents, fieldMask, this._requestTag, this._transactionId);

* set.
* @param {T} data The object to serialize as the document.
* @param {T|Partial<T>} data The object to serialize as the document.
* @param {SetOptions=} options An object to configure the set behavior.

@@ -222,2 +222,3 @@ * @param {boolean=} options.merge - If true, set() merges the values

update(documentRef, dataOrField, ...preconditionOrValues) {
// eslint-disable-next-line prefer-rest-params
validate_1.validateMinNumberOfArguments('Transaction.update', arguments, 2);

@@ -281,3 +282,3 @@ this._writeBatch.update(documentRef, dataOrField, ...preconditionOrValues);

return this._writeBatch
.commit_({
._commit({
transactionId: this._transactionId,

@@ -315,3 +316,3 @@ requestTag: this._requestTag,

if (lastError) {
logger_1.logger('Firestore.runTransaction', this._requestTag, `Retrying transaction after error:`, lastError);
logger_1.logger('Firestore.runTransaction', this._requestTag, 'Retrying transaction after error:', lastError);
}

@@ -318,0 +319,0 @@ this._writeBatch._reset();

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

/// <reference types="node" />
import { FirestoreDataConverter } from '@google-cloud/firestore';
import { CallOptions } from 'google-gax';

@@ -22,3 +23,2 @@ import { Duplex } from 'stream';

import { FieldPath } from './path';
import { Timestamp } from './timestamp';
import api = google.firestore.v1;

@@ -58,119 +58,7 @@ /**

/**
* Converter used by `withConverter()` to transform user objects of type T
* into Firestore data.
*
* Using the converter allows you to specify generic type arguments when
* storing and retrieving objects from Firestore.
*
* @example
* class Post {
* constructor(readonly title: string, readonly author: string) {}
*
* toString(): string {
* return this.title + ', by ' + this.author;
* }
* }
*
* const postConverter = {
* toFirestore(post: Post): FirebaseFirestore.DocumentData {
* return {title: post.title, author: post.author};
* },
* fromFirestore(
* data: FirebaseFirestore.DocumentData
* ): Post {
* return new Post(data.title, data.author);
* }
* };
*
* const postSnap = await Firestore()
* .collection('posts')
* .withConverter(postConverter)
* .doc().get();
* const post = postSnap.data();
* if (post !== undefined) {
* post.title; // string
* post.toString(); // Should be defined
* post.someNonExistentProperty; // TS error
* }
*/
export interface FirestoreDataConverter<T> {
/**
* Called by the Firestore SDK to convert a custom model object of type T
* into a plain Javascript object (suitable for writing directly to the
* Firestore database).
*/
toFirestore(modelObject: T): DocumentData;
/**
* Called by the Firestore SDK to convert Firestore data into an object of
* type T.
*/
fromFirestore(data: DocumentData): T;
}
/**
* A default converter to use when none is provided.
* @private
*/
export declare const defaultConverter: FirestoreDataConverter<DocumentData>;
export declare function defaultConverter<T>(): FirestoreDataConverter<T>;
/**
* Settings used to directly configure a `Firestore` instance.
*/
export interface Settings {
/**
* The Firestore Project ID. Can be omitted in environments that support
* `Application Default Credentials` {@see https://cloud.google.com/docs/authentication}
*/
projectId?: string;
/** The host to connect to. */
host?: string;
/**
* Local file containing the Service Account credentials. Can be omitted
* in environments that support `Application Default Credentials`
* {@see https://cloud.google.com/docs/authentication}
*/
keyFilename?: string;
/**
* The 'client_email' and 'private_key' properties of the service account
* to use with your Firestore project. Can be omitted in environments that
* support {@link https://cloud.google.com/docs/authentication Application
* Default Credentials}. If your credentials are stored in a JSON file, you
* can specify a `keyFilename` instead.
*/
credentials?: {
client_email?: string;
private_key?: string;
};
/** Whether to use SSL when connecting. */
ssl?: boolean;
/**
* The maximum number of idle GRPC channels to keep. A smaller number of idle
* channels reduces memory usage but increases request latency for clients
* with fluctuating request rates. If set to 0, shuts down all GRPC channels
* when the client becomes idle. Defaults to 1.
*/
maxIdleChannels?: number;
/**
* Whether to skip nested properties that are set to `undefined` during
* object serialization. If set to `true`, these properties are skipped
* and not written to Firestore. If set `false` or omitted, the SDK throws
* an exception when it encounters properties of type `undefined`.
*/
ignoreUndefinedProperties?: boolean;
[key: string]: any;
}
/**
* Document data (for use with `DocumentReference.set()`) consists of fields
* mapped to values.
*/
export interface DocumentData {
[field: string]: any;
}
/**
* Update data (for use with `DocumentReference.update()`) consists of field
* paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots
* reference nested fields within the document.
*/
export interface UpdateData {
[fieldPath: string]: unknown;
}
/**
* Update data that has been resolved to a mapping of FieldPaths to values.

@@ -180,63 +68,2 @@ */

/**
* The direction of a `Query.orderBy()` clause is specified as 'desc' or 'asc'
* (descending or ascending).
*/
export declare type OrderByDirection = 'desc' | 'asc';
/**
* Filter conditions in a `Query.where()` clause are specified using the
* strings '<', '<=', '==', '>=', '>','array-contains', 'in', and
* 'array-contains-any'.
*/
export declare type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>' | 'array-contains' | 'in' | 'array-contains-any';
/**
* An options object that configures conditional behavior of `update()` and
* `delete()` calls in `DocumentReference`, `WriteBatch`, and `Transaction`.
* Using Preconditions, these calls can be restricted to only apply to
* documents that match the specified restrictions.
*/
export interface Precondition {
/**
* If set, the last update time to enforce.
*/
readonly lastUpdateTime?: Timestamp;
}
/**
* An options object that configures the behavior of `set()` calls in
* `DocumentReference`, `WriteBatch` and `Transaction`. These calls can be
* configured to perform granular merges instead of overwriting the target
* documents in their entirety.
*/
export interface SetOptions {
/**
* Changes the behavior of a set() call to only replace the values specified
* in its data argument. Fields omitted from the set() call remain
* untouched.
*/
readonly merge?: boolean;
/**
* Changes the behavior of set() calls to only replace the specified field
* paths. Any field path that is not specified is ignored and remains
* untouched.
*
* It is an error to pass a SetOptions object to a set() call that is
* missing a value for any of the fields specified here.
*/
readonly mergeFields?: Array<string | FieldPath>;
}
/**
* An options object that can be used to configure the behavior of `getAll()`
* calls. By providing a `fieldMask`, these calls can be configured to only
* return a subset of fields.
*/
export interface ReadOptions {
/**
* Specifies the set of fields to return and reduces the amount of data
* transmitted by the backend.
*
* Adding a field mask does not filter results. Documents do not need to
* contain values for all the fields in the mask to be part of the result set.
*/
readonly fieldMask?: Array<string | FieldPath>;
}
/**
* Internal user data validation options.

@@ -243,0 +70,0 @@ * @private

@@ -20,12 +20,24 @@ "use strict";

* A default converter to use when none is provided.
*
* By declaring the converter as a variable instead of creating the object
* inside defaultConverter(), object equality when comparing default converters
* is preserved.
* @private
*/
exports.defaultConverter = {
const defaultConverterObj = {
toFirestore(modelObject) {
return modelObject;
},
fromFirestore(data) {
return data;
fromFirestore(snapshot) {
return snapshot.data();
},
};
/**
* A default converter to use when none is provided.
* @private
*/
function defaultConverter() {
return defaultConverterObj;
}
exports.defaultConverter = defaultConverter;
//# sourceMappingURL=types.js.map

@@ -16,5 +16,5 @@ /*!

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

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

/// <reference types="node" />
import * as gax from 'google-gax';
import { Callback, ClientOptions, LROperation } from 'google-gax';
import { Callback, Descriptors, ClientOptions, LROperation, PaginationCallback } from 'google-gax';
import { Transform } from 'stream';
import * as protosTypes from '../../protos/firestore_admin_v1_proto_api';
import * as protos from '../../protos/firestore_admin_v1_proto_api';
/**

@@ -13,5 +13,2 @@ * Operations are created by service `FirestoreAdmin`, but are accessed via

export declare class FirestoreAdminClient {
private _descriptors;
private _innerApiCalls;
private _pathTemplates;
private _terminated;

@@ -24,2 +21,9 @@ private _opts;

auth: gax.GoogleAuth;
descriptors: Descriptors;
innerApiCalls: {
[name: string]: Function;
};
pathTemplates: {
[name: string]: gax.PathTemplate;
};
operationsClient: gax.OperationsClient;

@@ -89,19 +93,87 @@ firestoreAdminStub?: Promise<{

getProjectId(callback: Callback<string, undefined, undefined>): void;
getIndex(request: protosTypes.google.firestore.admin.v1.IGetIndexRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.admin.v1.IIndex, protosTypes.google.firestore.admin.v1.IGetIndexRequest | undefined, {} | undefined]>;
getIndex(request: protosTypes.google.firestore.admin.v1.IGetIndexRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.admin.v1.IIndex, protosTypes.google.firestore.admin.v1.IGetIndexRequest | undefined, {} | undefined>): void;
deleteIndex(request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest, options?: gax.CallOptions): Promise<[protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.admin.v1.IDeleteIndexRequest | undefined, {} | undefined]>;
deleteIndex(request: protosTypes.google.firestore.admin.v1.IDeleteIndexRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.admin.v1.IDeleteIndexRequest | undefined, {} | undefined>): void;
getField(request: protosTypes.google.firestore.admin.v1.IGetFieldRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.admin.v1.IField, protosTypes.google.firestore.admin.v1.IGetFieldRequest | undefined, {} | undefined]>;
getField(request: protosTypes.google.firestore.admin.v1.IGetFieldRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.admin.v1.IField, protosTypes.google.firestore.admin.v1.IGetFieldRequest | undefined, {} | undefined>): void;
createIndex(request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest, options?: gax.CallOptions): Promise<[LROperation<protosTypes.google.firestore.admin.v1.IIndex, protosTypes.google.firestore.admin.v1.IIndexOperationMetadata>, protosTypes.google.longrunning.IOperation | undefined, {} | undefined]>;
createIndex(request: protosTypes.google.firestore.admin.v1.ICreateIndexRequest, options: gax.CallOptions, callback: Callback<LROperation<protosTypes.google.firestore.admin.v1.IIndex, protosTypes.google.firestore.admin.v1.IIndexOperationMetadata>, protosTypes.google.longrunning.IOperation | undefined, {} | undefined>): void;
updateField(request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest, options?: gax.CallOptions): Promise<[LROperation<protosTypes.google.firestore.admin.v1.IField, protosTypes.google.firestore.admin.v1.IFieldOperationMetadata>, protosTypes.google.longrunning.IOperation | undefined, {} | undefined]>;
updateField(request: protosTypes.google.firestore.admin.v1.IUpdateFieldRequest, options: gax.CallOptions, callback: Callback<LROperation<protosTypes.google.firestore.admin.v1.IField, protosTypes.google.firestore.admin.v1.IFieldOperationMetadata>, protosTypes.google.longrunning.IOperation | undefined, {} | undefined>): void;
exportDocuments(request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest, options?: gax.CallOptions): Promise<[LROperation<protosTypes.google.firestore.admin.v1.IExportDocumentsResponse, protosTypes.google.firestore.admin.v1.IExportDocumentsMetadata>, protosTypes.google.longrunning.IOperation | undefined, {} | undefined]>;
exportDocuments(request: protosTypes.google.firestore.admin.v1.IExportDocumentsRequest, options: gax.CallOptions, callback: Callback<LROperation<protosTypes.google.firestore.admin.v1.IExportDocumentsResponse, protosTypes.google.firestore.admin.v1.IExportDocumentsMetadata>, protosTypes.google.longrunning.IOperation | undefined, {} | undefined>): void;
importDocuments(request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest, options?: gax.CallOptions): Promise<[LROperation<protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.admin.v1.IImportDocumentsMetadata>, protosTypes.google.longrunning.IOperation | undefined, {} | undefined]>;
importDocuments(request: protosTypes.google.firestore.admin.v1.IImportDocumentsRequest, options: gax.CallOptions, callback: Callback<LROperation<protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.admin.v1.IImportDocumentsMetadata>, protosTypes.google.longrunning.IOperation | undefined, {} | undefined>): void;
listIndexes(request: protosTypes.google.firestore.admin.v1.IListIndexesRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.admin.v1.IIndex[], protosTypes.google.firestore.admin.v1.IListIndexesRequest | null, protosTypes.google.firestore.admin.v1.IListIndexesResponse]>;
listIndexes(request: protosTypes.google.firestore.admin.v1.IListIndexesRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.admin.v1.IIndex[], protosTypes.google.firestore.admin.v1.IListIndexesRequest | null, protosTypes.google.firestore.admin.v1.IListIndexesResponse>): void;
getIndex(request: protos.google.firestore.admin.v1.IGetIndexRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.admin.v1.IIndex, protos.google.firestore.admin.v1.IGetIndexRequest | undefined, {} | undefined]>;
getIndex(request: protos.google.firestore.admin.v1.IGetIndexRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.admin.v1.IIndex, protos.google.firestore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined>): void;
getIndex(request: protos.google.firestore.admin.v1.IGetIndexRequest, callback: Callback<protos.google.firestore.admin.v1.IIndex, protos.google.firestore.admin.v1.IGetIndexRequest | null | undefined, {} | null | undefined>): void;
deleteIndex(request: protos.google.firestore.admin.v1.IDeleteIndexRequest, options?: gax.CallOptions): Promise<[protos.google.protobuf.IEmpty, protos.google.firestore.admin.v1.IDeleteIndexRequest | undefined, {} | undefined]>;
deleteIndex(request: protos.google.firestore.admin.v1.IDeleteIndexRequest, options: gax.CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.firestore.admin.v1.IDeleteIndexRequest | null | undefined, {} | null | undefined>): void;
deleteIndex(request: protos.google.firestore.admin.v1.IDeleteIndexRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.firestore.admin.v1.IDeleteIndexRequest | null | undefined, {} | null | undefined>): void;
getField(request: protos.google.firestore.admin.v1.IGetFieldRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.admin.v1.IField, protos.google.firestore.admin.v1.IGetFieldRequest | undefined, {} | undefined]>;
getField(request: protos.google.firestore.admin.v1.IGetFieldRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.admin.v1.IField, protos.google.firestore.admin.v1.IGetFieldRequest | null | undefined, {} | null | undefined>): void;
getField(request: protos.google.firestore.admin.v1.IGetFieldRequest, callback: Callback<protos.google.firestore.admin.v1.IField, protos.google.firestore.admin.v1.IGetFieldRequest | null | undefined, {} | null | undefined>): void;
createIndex(request: protos.google.firestore.admin.v1.ICreateIndexRequest, options?: gax.CallOptions): Promise<[LROperation<protos.google.firestore.admin.v1.IIndex, protos.google.firestore.admin.v1.IIndexOperationMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined]>;
createIndex(request: protos.google.firestore.admin.v1.ICreateIndexRequest, options: gax.CallOptions, callback: Callback<LROperation<protos.google.firestore.admin.v1.IIndex, protos.google.firestore.admin.v1.IIndexOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
createIndex(request: protos.google.firestore.admin.v1.ICreateIndexRequest, callback: Callback<LROperation<protos.google.firestore.admin.v1.IIndex, protos.google.firestore.admin.v1.IIndexOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
/**
* Check the status of the long running operation returned by the createIndex() method.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
*
* @example:
* const decodedOperation = await checkCreateIndexProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*
*/
checkCreateIndexProgress(name: string): Promise<LROperation<protos.google.firestore.admin.v1.Index, protos.google.firestore.admin.v1.IndexOperationMetadata>>;
updateField(request: protos.google.firestore.admin.v1.IUpdateFieldRequest, options?: gax.CallOptions): Promise<[LROperation<protos.google.firestore.admin.v1.IField, protos.google.firestore.admin.v1.IFieldOperationMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined]>;
updateField(request: protos.google.firestore.admin.v1.IUpdateFieldRequest, options: gax.CallOptions, callback: Callback<LROperation<protos.google.firestore.admin.v1.IField, protos.google.firestore.admin.v1.IFieldOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
updateField(request: protos.google.firestore.admin.v1.IUpdateFieldRequest, callback: Callback<LROperation<protos.google.firestore.admin.v1.IField, protos.google.firestore.admin.v1.IFieldOperationMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
/**
* Check the status of the long running operation returned by the updateField() method.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
*
* @example:
* const decodedOperation = await checkUpdateFieldProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*
*/
checkUpdateFieldProgress(name: string): Promise<LROperation<protos.google.firestore.admin.v1.Field, protos.google.firestore.admin.v1.FieldOperationMetadata>>;
exportDocuments(request: protos.google.firestore.admin.v1.IExportDocumentsRequest, options?: gax.CallOptions): Promise<[LROperation<protos.google.firestore.admin.v1.IExportDocumentsResponse, protos.google.firestore.admin.v1.IExportDocumentsMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined]>;
exportDocuments(request: protos.google.firestore.admin.v1.IExportDocumentsRequest, options: gax.CallOptions, callback: Callback<LROperation<protos.google.firestore.admin.v1.IExportDocumentsResponse, protos.google.firestore.admin.v1.IExportDocumentsMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
exportDocuments(request: protos.google.firestore.admin.v1.IExportDocumentsRequest, callback: Callback<LROperation<protos.google.firestore.admin.v1.IExportDocumentsResponse, protos.google.firestore.admin.v1.IExportDocumentsMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
/**
* Check the status of the long running operation returned by the exportDocuments() method.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
*
* @example:
* const decodedOperation = await checkExportDocumentsProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*
*/
checkExportDocumentsProgress(name: string): Promise<LROperation<protos.google.firestore.admin.v1.ExportDocumentsResponse, protos.google.firestore.admin.v1.ExportDocumentsMetadata>>;
importDocuments(request: protos.google.firestore.admin.v1.IImportDocumentsRequest, options?: gax.CallOptions): Promise<[LROperation<protos.google.protobuf.IEmpty, protos.google.firestore.admin.v1.IImportDocumentsMetadata>, protos.google.longrunning.IOperation | undefined, {} | undefined]>;
importDocuments(request: protos.google.firestore.admin.v1.IImportDocumentsRequest, options: gax.CallOptions, callback: Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.firestore.admin.v1.IImportDocumentsMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
importDocuments(request: protos.google.firestore.admin.v1.IImportDocumentsRequest, callback: Callback<LROperation<protos.google.protobuf.IEmpty, protos.google.firestore.admin.v1.IImportDocumentsMetadata>, protos.google.longrunning.IOperation | null | undefined, {} | null | undefined>): void;
/**
* Check the status of the long running operation returned by the importDocuments() method.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
*
* @example:
* const decodedOperation = await checkImportDocumentsProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*
*/
checkImportDocumentsProgress(name: string): Promise<LROperation<protos.google.protobuf.Empty, protos.google.firestore.admin.v1.ImportDocumentsMetadata>>;
listIndexes(request: protos.google.firestore.admin.v1.IListIndexesRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.admin.v1.IIndex[], protos.google.firestore.admin.v1.IListIndexesRequest | null, protos.google.firestore.admin.v1.IListIndexesResponse]>;
listIndexes(request: protos.google.firestore.admin.v1.IListIndexesRequest, options: gax.CallOptions, callback: PaginationCallback<protos.google.firestore.admin.v1.IListIndexesRequest, protos.google.firestore.admin.v1.IListIndexesResponse | null | undefined, protos.google.firestore.admin.v1.IIndex>): void;
listIndexes(request: protos.google.firestore.admin.v1.IListIndexesRequest, callback: PaginationCallback<protos.google.firestore.admin.v1.IListIndexesRequest, protos.google.firestore.admin.v1.IListIndexesResponse | null | undefined, protos.google.firestore.admin.v1.IIndex>): void;
/**
* Equivalent to {@link listIndexes}, but returns a NodeJS Stream object.

@@ -137,6 +209,31 @@ *

*/
listIndexesStream(request?: protosTypes.google.firestore.admin.v1.IListIndexesRequest, options?: gax.CallOptions): Transform;
listFields(request: protosTypes.google.firestore.admin.v1.IListFieldsRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.admin.v1.IField[], protosTypes.google.firestore.admin.v1.IListFieldsRequest | null, protosTypes.google.firestore.admin.v1.IListFieldsResponse]>;
listFields(request: protosTypes.google.firestore.admin.v1.IListFieldsRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.admin.v1.IField[], protosTypes.google.firestore.admin.v1.IListFieldsRequest | null, protosTypes.google.firestore.admin.v1.IListFieldsResponse>): void;
listIndexesStream(request?: protos.google.firestore.admin.v1.IListIndexesRequest, options?: gax.CallOptions): Transform;
/**
* Equivalent to {@link listIndexes}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. A parent name of the form
* `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
* @param {string} request.filter
* The filter to apply to list results.
* @param {number} request.pageSize
* The number of results to return.
* @param {string} request.pageToken
* A page token, returned from a previous call to
* {@link google.firestore.admin.v1.FirestoreAdmin.ListIndexes|FirestoreAdmin.ListIndexes}, that may be used to get the next
* page of results.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listIndexesAsync(request?: protos.google.firestore.admin.v1.IListIndexesRequest, options?: gax.CallOptions): AsyncIterable<protos.google.firestore.admin.v1.IIndex>;
listFields(request: protos.google.firestore.admin.v1.IListFieldsRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.admin.v1.IField[], protos.google.firestore.admin.v1.IListFieldsRequest | null, protos.google.firestore.admin.v1.IListFieldsResponse]>;
listFields(request: protos.google.firestore.admin.v1.IListFieldsRequest, options: gax.CallOptions, callback: PaginationCallback<protos.google.firestore.admin.v1.IListFieldsRequest, protos.google.firestore.admin.v1.IListFieldsResponse | null | undefined, protos.google.firestore.admin.v1.IField>): void;
listFields(request: protos.google.firestore.admin.v1.IListFieldsRequest, callback: PaginationCallback<protos.google.firestore.admin.v1.IListFieldsRequest, protos.google.firestore.admin.v1.IListFieldsResponse | null | undefined, protos.google.firestore.admin.v1.IField>): void;
/**
* Equivalent to {@link listFields}, but returns a NodeJS Stream object.

@@ -176,4 +273,32 @@ *

*/
listFieldsStream(request?: protosTypes.google.firestore.admin.v1.IListFieldsRequest, options?: gax.CallOptions): Transform;
listFieldsStream(request?: protos.google.firestore.admin.v1.IListFieldsRequest, options?: gax.CallOptions): Transform;
/**
* Equivalent to {@link listFields}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. A parent name of the form
* `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
* @param {string} request.filter
* The filter to apply to list results. Currently,
* {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields
* that have been explicitly overridden. To issue this query, call
* {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with the filter set to
* `indexConfig.usesAncestorConfig:false`.
* @param {number} request.pageSize
* The number of results to return.
* @param {string} request.pageToken
* A page token, returned from a previous call to
* {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields}, that may be used to get the next
* page of results.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listFieldsAsync(request?: protos.google.firestore.admin.v1.IListFieldsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.firestore.admin.v1.IField>;
/**
* Return a fully-qualified collectionGroup resource name string.

@@ -194,3 +319,3 @@ *

*/
matchProjectFromCollectionGroupName(collectionGroupName: string): string;
matchProjectFromCollectionGroupName(collectionGroupName: string): string | number;
/**

@@ -203,3 +328,3 @@ * Parse the database from CollectionGroup resource.

*/
matchDatabaseFromCollectionGroupName(collectionGroupName: string): string;
matchDatabaseFromCollectionGroupName(collectionGroupName: string): string | number;
/**

@@ -212,3 +337,3 @@ * Parse the collection from CollectionGroup resource.

*/
matchCollectionFromCollectionGroupName(collectionGroupName: string): string;
matchCollectionFromCollectionGroupName(collectionGroupName: string): string | number;
/**

@@ -229,3 +354,3 @@ * Return a fully-qualified database resource name string.

*/
matchProjectFromDatabaseName(databaseName: string): string;
matchProjectFromDatabaseName(databaseName: string): string | number;
/**

@@ -238,3 +363,3 @@ * Parse the database from Database resource.

*/
matchDatabaseFromDatabaseName(databaseName: string): string;
matchDatabaseFromDatabaseName(databaseName: string): string | number;
/**

@@ -257,3 +382,3 @@ * Return a fully-qualified field resource name string.

*/
matchProjectFromFieldName(fieldName: string): string;
matchProjectFromFieldName(fieldName: string): string | number;
/**

@@ -266,3 +391,3 @@ * Parse the database from Field resource.

*/
matchDatabaseFromFieldName(fieldName: string): string;
matchDatabaseFromFieldName(fieldName: string): string | number;
/**

@@ -275,3 +400,3 @@ * Parse the collection from Field resource.

*/
matchCollectionFromFieldName(fieldName: string): string;
matchCollectionFromFieldName(fieldName: string): string | number;
/**

@@ -284,3 +409,3 @@ * Parse the field from Field resource.

*/
matchFieldFromFieldName(fieldName: string): string;
matchFieldFromFieldName(fieldName: string): string | number;
/**

@@ -303,3 +428,3 @@ * Return a fully-qualified index resource name string.

*/
matchProjectFromIndexName(indexName: string): string;
matchProjectFromIndexName(indexName: string): string | number;
/**

@@ -312,3 +437,3 @@ * Parse the database from Index resource.

*/
matchDatabaseFromIndexName(indexName: string): string;
matchDatabaseFromIndexName(indexName: string): string | number;
/**

@@ -321,3 +446,3 @@ * Parse the collection from Index resource.

*/
matchCollectionFromIndexName(indexName: string): string;
matchCollectionFromIndexName(indexName: string): string | number;
/**

@@ -330,3 +455,3 @@ * Parse the index from Index resource.

*/
matchIndexFromIndexName(indexName: string): string;
matchIndexFromIndexName(indexName: string): string | number;
/**

@@ -333,0 +458,0 @@ * Terminate the GRPC channel and close the client.

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

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

@@ -58,3 +59,4 @@ /**

constructor(opts) {
this._descriptors = {
this._terminated = false;
this.descriptors = {
page: {},

@@ -65,3 +67,2 @@ stream: {},

};
this._terminated = false;
// Ensure that options include the service address and port.

@@ -80,11 +81,14 @@ const staticMembers = this.constructor;

opts.port = opts.port || port;
// users can override the config from client side, like retry codes name.
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
// The way to override client config for Showcase API:
//
// const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};
const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
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.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the FirestoreAdminClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;
// Create a `gaxGrpc` object, with any grpc-specific options

@@ -116,7 +120,10 @@ // sent to the client.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
this._protos = this._gaxGrpc.loadProto(opts.fallback
? // eslint-disable-next-line @typescript-eslint/no-var-requires
require('../../protos/protos.json')
: nodejsProtoPath);
// This API contains "path templates"; forward-slash-separated
// identifiers to uniquely identify resources within the API.
// Create useful helper objects for these.
this._pathTemplates = {
this.pathTemplates = {
collectionGroupPathTemplate: new this._gaxModule.PathTemplate('projects/{project}/databases/{database}/collectionGroups/{collection}'),

@@ -130,3 +137,3 @@ databasePathTemplate: new this._gaxModule.PathTemplate('projects/{project}/databases/{database}'),

// pages). Denote the keys used for pagination and results.
this._descriptors.page = {
this.descriptors.page = {
listIndexes: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'indexes'),

@@ -139,3 +146,5 @@ listFields: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'fields'),

const protoFilesRoot = opts.fallback
? this._gaxModule.protobuf.Root.fromJSON(require('../../protos/protos.json'))
? this._gaxModule.protobuf.Root.fromJSON(
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('../../protos/protos.json'))
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);

@@ -156,3 +165,3 @@ this.operationsClient = this._gaxModule

const importDocumentsMetadata = protoFilesRoot.lookup('.google.firestore.admin.v1.ImportDocumentsMetadata');
this._descriptors.longrunning = {
this.descriptors.longrunning = {
createIndex: new this._gaxModule.LongrunningDescriptor(this.operationsClient, createIndexResponse.decode.bind(createIndexResponse), createIndexMetadata.decode.bind(createIndexMetadata)),

@@ -168,3 +177,3 @@ updateField: new this._gaxModule.LongrunningDescriptor(this.operationsClient, updateFieldResponse.decode.bind(updateFieldResponse), updateFieldMetadata.decode.bind(updateFieldMetadata)),

// merely providing the destination and request information.
this._innerApiCalls = {};
this.innerApiCalls = {};
}

@@ -191,3 +200,3 @@ /**

? this._protos.lookupService('google.firestore.admin.v1.FirestoreAdmin')
: // tslint:disable-next-line no-any
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
this._protos.google.firestore.admin.v1.FirestoreAdmin, this._opts);

@@ -208,5 +217,5 @@ // Iterate over each of the methods that the service provides

for (const methodName of firestoreAdminStubMethods) {
const innerCallPromise = this.firestoreAdminStub.then(stub => (...args) => {
const callPromise = this.firestoreAdminStub.then(stub => (...args) => {
if (this._terminated) {
return Promise.reject(new Error('The client has already been closed.'));
return Promise.reject('The client has already been closed.');
}

@@ -218,8 +227,6 @@ const func = stub[methodName];

});
const apiCall = this._gaxModule.createApiCall(innerCallPromise, this._defaults[methodName], this._descriptors.page[methodName] ||
this._descriptors.stream[methodName] ||
this._descriptors.longrunning[methodName]);
this._innerApiCalls[methodName] = (argument, callOptions, callback) => {
return apiCall(argument, callOptions, callback);
};
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], this.descriptors.page[methodName] ||
this.descriptors.stream[methodName] ||
this.descriptors.longrunning[methodName]);
this.innerApiCalls[methodName] = apiCall;
}

@@ -300,3 +307,3 @@ return this.firestoreAdminStub;

this.initialize();
return this._innerApiCalls.getIndex(request, options, callback);
return this.innerApiCalls.getIndex(request, options, callback);
}

@@ -334,3 +341,3 @@ /**

this.initialize();
return this._innerApiCalls.deleteIndex(request, options, callback);
return this.innerApiCalls.deleteIndex(request, options, callback);
}

@@ -368,3 +375,3 @@ /**

this.initialize();
return this._innerApiCalls.getField(request, options, callback);
return this.innerApiCalls.getField(request, options, callback);
}

@@ -406,5 +413,25 @@ /**

this.initialize();
return this._innerApiCalls.createIndex(request, options, callback);
return this.innerApiCalls.createIndex(request, options, callback);
}
/**
* Check the status of the long running operation returned by the createIndex() method.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
*
* @example:
* const decodedOperation = await checkCreateIndexProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*
*/
async checkCreateIndexProgress(name) {
const request = new google_gax_1.operationsProtos.google.longrunning.GetOperationRequest({ name });
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.createIndex, gax.createDefaultBackoffSettings());
return decodeOperation;
}
/**
* Updates a field configuration. Currently, field updates apply only to

@@ -454,5 +481,25 @@ * single field index configuration. However, calls to

this.initialize();
return this._innerApiCalls.updateField(request, options, callback);
return this.innerApiCalls.updateField(request, options, callback);
}
/**
* Check the status of the long running operation returned by the updateField() method.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
*
* @example:
* const decodedOperation = await checkUpdateFieldProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*
*/
async checkUpdateFieldProgress(name) {
const request = new google_gax_1.operationsProtos.google.longrunning.GetOperationRequest({ name });
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.updateField, gax.createDefaultBackoffSettings());
return decodeOperation;
}
/**
* Exports a copy of all or a subset of documents from Google Cloud Firestore

@@ -506,5 +553,25 @@ * to another storage system, such as Google Cloud Storage. Recent updates to

this.initialize();
return this._innerApiCalls.exportDocuments(request, options, callback);
return this.innerApiCalls.exportDocuments(request, options, callback);
}
/**
* Check the status of the long running operation returned by the exportDocuments() method.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
*
* @example:
* const decodedOperation = await checkExportDocumentsProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*
*/
async checkExportDocumentsProgress(name) {
const request = new google_gax_1.operationsProtos.google.longrunning.GetOperationRequest({ name });
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.exportDocuments, gax.createDefaultBackoffSettings());
return decodeOperation;
}
/**
* Imports documents into Google Cloud Firestore. Existing documents with the

@@ -553,5 +620,25 @@ * same name are overwritten. The import occurs in the background and its

this.initialize();
return this._innerApiCalls.importDocuments(request, options, callback);
return this.innerApiCalls.importDocuments(request, options, callback);
}
/**
* Check the status of the long running operation returned by the importDocuments() method.
* @param {String} name
* The operation name that will be passed.
* @returns {Promise} - The promise which resolves to an object.
* The decoded operation object has result and metadata field to get information from.
*
* @example:
* const decodedOperation = await checkImportDocumentsProgress(name);
* console.log(decodedOperation.result);
* console.log(decodedOperation.done);
* console.log(decodedOperation.metadata);
*
*/
async checkImportDocumentsProgress(name) {
const request = new google_gax_1.operationsProtos.google.longrunning.GetOperationRequest({ name });
const [operation] = await this.operationsClient.getOperation(request);
const decodeOperation = new gax.Operation(operation, this.descriptors.longrunning.importDocuments, gax.createDefaultBackoffSettings());
return decodeOperation;
}
/**
* Lists composite indexes.

@@ -607,3 +694,3 @@ *

this.initialize();
return this._innerApiCalls.listIndexes(request, options, callback);
return this.innerApiCalls.listIndexes(request, options, callback);
}

@@ -651,5 +738,41 @@ /**

this.initialize();
return this._descriptors.page.listIndexes.createStream(this._innerApiCalls.listIndexes, request, callSettings);
return this.descriptors.page.listIndexes.createStream(this.innerApiCalls.listIndexes, request, callSettings);
}
/**
* Equivalent to {@link listIndexes}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. A parent name of the form
* `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
* @param {string} request.filter
* The filter to apply to list results.
* @param {number} request.pageSize
* The number of results to return.
* @param {string} request.pageToken
* A page token, returned from a previous call to
* {@link google.firestore.admin.v1.FirestoreAdmin.ListIndexes|FirestoreAdmin.ListIndexes}, that may be used to get the next
* page of results.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listIndexesAsync(request, options) {
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listIndexes.asyncIterate(this.innerApiCalls['listIndexes'], request, callSettings);
}
/**
* Lists the field configuration and metadata for this database.

@@ -714,3 +837,3 @@ *

this.initialize();
return this._innerApiCalls.listFields(request, options, callback);
return this.innerApiCalls.listFields(request, options, callback);
}

@@ -762,4 +885,44 @@ /**

this.initialize();
return this._descriptors.page.listFields.createStream(this._innerApiCalls.listFields, request, callSettings);
return this.descriptors.page.listFields.createStream(this.innerApiCalls.listFields, request, callSettings);
}
/**
* Equivalent to {@link listFields}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. A parent name of the form
* `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
* @param {string} request.filter
* The filter to apply to list results. Currently,
* {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} only supports listing fields
* that have been explicitly overridden. To issue this query, call
* {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields} with the filter set to
* `indexConfig.usesAncestorConfig:false`.
* @param {number} request.pageSize
* The number of results to return.
* @param {string} request.pageToken
* A page token, returned from a previous call to
* {@link google.firestore.admin.v1.FirestoreAdmin.ListFields|FirestoreAdmin.ListFields}, that may be used to get the next
* page of results.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listFieldsAsync(request, options) {
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listFields.asyncIterate(this.innerApiCalls['listFields'], request, callSettings);
}
// --------------------

@@ -777,6 +940,6 @@ // -- Path templates --

collectionGroupPath(project, database, collection) {
return this._pathTemplates.collectionGroupPathTemplate.render({
project,
database,
collection,
return this.pathTemplates.collectionGroupPathTemplate.render({
project: project,
database: database,
collection: collection,
});

@@ -792,3 +955,3 @@ }

matchProjectFromCollectionGroupName(collectionGroupName) {
return this._pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).project;
return this.pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).project;
}

@@ -803,3 +966,3 @@ /**

matchDatabaseFromCollectionGroupName(collectionGroupName) {
return this._pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).database;
return this.pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).database;
}

@@ -814,3 +977,3 @@ /**

matchCollectionFromCollectionGroupName(collectionGroupName) {
return this._pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).collection;
return this.pathTemplates.collectionGroupPathTemplate.match(collectionGroupName).collection;
}

@@ -825,5 +988,5 @@ /**

databasePath(project, database) {
return this._pathTemplates.databasePathTemplate.render({
project,
database,
return this.pathTemplates.databasePathTemplate.render({
project: project,
database: database,
});

@@ -839,3 +1002,3 @@ }

matchProjectFromDatabaseName(databaseName) {
return this._pathTemplates.databasePathTemplate.match(databaseName).project;
return this.pathTemplates.databasePathTemplate.match(databaseName).project;
}

@@ -850,4 +1013,3 @@ /**

matchDatabaseFromDatabaseName(databaseName) {
return this._pathTemplates.databasePathTemplate.match(databaseName)
.database;
return this.pathTemplates.databasePathTemplate.match(databaseName).database;
}

@@ -864,7 +1026,7 @@ /**

fieldPath(project, database, collection, field) {
return this._pathTemplates.fieldPathTemplate.render({
project,
database,
collection,
field,
return this.pathTemplates.fieldPathTemplate.render({
project: project,
database: database,
collection: collection,
field: field,
});

@@ -880,3 +1042,3 @@ }

matchProjectFromFieldName(fieldName) {
return this._pathTemplates.fieldPathTemplate.match(fieldName).project;
return this.pathTemplates.fieldPathTemplate.match(fieldName).project;
}

@@ -891,3 +1053,3 @@ /**

matchDatabaseFromFieldName(fieldName) {
return this._pathTemplates.fieldPathTemplate.match(fieldName).database;
return this.pathTemplates.fieldPathTemplate.match(fieldName).database;
}

@@ -902,3 +1064,3 @@ /**

matchCollectionFromFieldName(fieldName) {
return this._pathTemplates.fieldPathTemplate.match(fieldName).collection;
return this.pathTemplates.fieldPathTemplate.match(fieldName).collection;
}

@@ -913,3 +1075,3 @@ /**

matchFieldFromFieldName(fieldName) {
return this._pathTemplates.fieldPathTemplate.match(fieldName).field;
return this.pathTemplates.fieldPathTemplate.match(fieldName).field;
}

@@ -926,7 +1088,7 @@ /**

indexPath(project, database, collection, index) {
return this._pathTemplates.indexPathTemplate.render({
project,
database,
collection,
index,
return this.pathTemplates.indexPathTemplate.render({
project: project,
database: database,
collection: collection,
index: index,
});

@@ -942,3 +1104,3 @@ }

matchProjectFromIndexName(indexName) {
return this._pathTemplates.indexPathTemplate.match(indexName).project;
return this.pathTemplates.indexPathTemplate.match(indexName).project;
}

@@ -953,3 +1115,3 @@ /**

matchDatabaseFromIndexName(indexName) {
return this._pathTemplates.indexPathTemplate.match(indexName).database;
return this.pathTemplates.indexPathTemplate.match(indexName).database;
}

@@ -964,3 +1126,3 @@ /**

matchCollectionFromIndexName(indexName) {
return this._pathTemplates.indexPathTemplate.match(indexName).collection;
return this.pathTemplates.indexPathTemplate.match(indexName).collection;
}

@@ -975,3 +1137,3 @@ /**

matchIndexFromIndexName(indexName) {
return this._pathTemplates.indexPathTemplate.match(indexName).index;
return this.pathTemplates.indexPathTemplate.match(indexName).index;
}

@@ -978,0 +1140,0 @@ /**

@@ -14,2 +14,5 @@ {

"UNAVAILABLE"
],
"unavailable": [
"UNAVAILABLE"
]

@@ -41,3 +44,3 @@ },

"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_codes_name": "unavailable",
"retry_params_name": "default"

@@ -62,3 +65,3 @@ },

"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_codes_name": "unavailable",
"retry_params_name": "default"

@@ -76,2 +79,6 @@ },

},
"PartitionQuery": {
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"Write": {

@@ -92,5 +99,9 @@ "timeout_millis": 86400000,

},
"BatchWrite": {
"retry_codes_name": "non_idempotent",
"retry_params_name": "default"
},
"CreateDocument": {
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_codes_name": "unavailable",
"retry_params_name": "default"

@@ -97,0 +108,0 @@ }

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

@@ -19,4 +19,2 @@ * The Cloud Firestore service.

export declare class FirestoreClient {
private _descriptors;
private _innerApiCalls;
private _terminated;

@@ -29,2 +27,6 @@ private _opts;

auth: gax.GoogleAuth;
descriptors: Descriptors;
innerApiCalls: {
[name: string]: Function;
};
firestoreStub?: Promise<{

@@ -93,16 +95,26 @@ [name: string]: Function;

getProjectId(callback: Callback<string, undefined, undefined>): void;
getDocument(request: protosTypes.google.firestore.v1.IGetDocumentRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1.IDocument, protosTypes.google.firestore.v1.IGetDocumentRequest | undefined, {} | undefined]>;
getDocument(request: protosTypes.google.firestore.v1.IGetDocumentRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1.IDocument, protosTypes.google.firestore.v1.IGetDocumentRequest | undefined, {} | undefined>): void;
updateDocument(request: protosTypes.google.firestore.v1.IUpdateDocumentRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1.IDocument, protosTypes.google.firestore.v1.IUpdateDocumentRequest | undefined, {} | undefined]>;
updateDocument(request: protosTypes.google.firestore.v1.IUpdateDocumentRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1.IDocument, protosTypes.google.firestore.v1.IUpdateDocumentRequest | undefined, {} | undefined>): void;
deleteDocument(request: protosTypes.google.firestore.v1.IDeleteDocumentRequest, options?: gax.CallOptions): Promise<[protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.v1.IDeleteDocumentRequest | undefined, {} | undefined]>;
deleteDocument(request: protosTypes.google.firestore.v1.IDeleteDocumentRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.v1.IDeleteDocumentRequest | undefined, {} | undefined>): void;
beginTransaction(request: protosTypes.google.firestore.v1.IBeginTransactionRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1.IBeginTransactionResponse, protosTypes.google.firestore.v1.IBeginTransactionRequest | undefined, {} | undefined]>;
beginTransaction(request: protosTypes.google.firestore.v1.IBeginTransactionRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1.IBeginTransactionResponse, protosTypes.google.firestore.v1.IBeginTransactionRequest | undefined, {} | undefined>): void;
commit(request: protosTypes.google.firestore.v1.ICommitRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1.ICommitResponse, protosTypes.google.firestore.v1.ICommitRequest | undefined, {} | undefined]>;
commit(request: protosTypes.google.firestore.v1.ICommitRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1.ICommitResponse, protosTypes.google.firestore.v1.ICommitRequest | undefined, {} | undefined>): void;
rollback(request: protosTypes.google.firestore.v1.IRollbackRequest, options?: gax.CallOptions): Promise<[protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.v1.IRollbackRequest | undefined, {} | undefined]>;
rollback(request: protosTypes.google.firestore.v1.IRollbackRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.v1.IRollbackRequest | undefined, {} | undefined>): void;
createDocument(request: protosTypes.google.firestore.v1.ICreateDocumentRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1.IDocument, protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, {} | undefined]>;
createDocument(request: protosTypes.google.firestore.v1.ICreateDocumentRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1.IDocument, protosTypes.google.firestore.v1.ICreateDocumentRequest | undefined, {} | undefined>): void;
getDocument(request: protos.google.firestore.v1.IGetDocumentRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1.IDocument, protos.google.firestore.v1.IGetDocumentRequest | undefined, {} | undefined]>;
getDocument(request: protos.google.firestore.v1.IGetDocumentRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1.IDocument, protos.google.firestore.v1.IGetDocumentRequest | null | undefined, {} | null | undefined>): void;
getDocument(request: protos.google.firestore.v1.IGetDocumentRequest, callback: Callback<protos.google.firestore.v1.IDocument, protos.google.firestore.v1.IGetDocumentRequest | null | undefined, {} | null | undefined>): void;
updateDocument(request: protos.google.firestore.v1.IUpdateDocumentRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1.IDocument, protos.google.firestore.v1.IUpdateDocumentRequest | undefined, {} | undefined]>;
updateDocument(request: protos.google.firestore.v1.IUpdateDocumentRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1.IDocument, protos.google.firestore.v1.IUpdateDocumentRequest | null | undefined, {} | null | undefined>): void;
updateDocument(request: protos.google.firestore.v1.IUpdateDocumentRequest, callback: Callback<protos.google.firestore.v1.IDocument, protos.google.firestore.v1.IUpdateDocumentRequest | null | undefined, {} | null | undefined>): void;
deleteDocument(request: protos.google.firestore.v1.IDeleteDocumentRequest, options?: gax.CallOptions): Promise<[protos.google.protobuf.IEmpty, protos.google.firestore.v1.IDeleteDocumentRequest | undefined, {} | undefined]>;
deleteDocument(request: protos.google.firestore.v1.IDeleteDocumentRequest, options: gax.CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.firestore.v1.IDeleteDocumentRequest | null | undefined, {} | null | undefined>): void;
deleteDocument(request: protos.google.firestore.v1.IDeleteDocumentRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.firestore.v1.IDeleteDocumentRequest | null | undefined, {} | null | undefined>): void;
beginTransaction(request: protos.google.firestore.v1.IBeginTransactionRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1.IBeginTransactionResponse, protos.google.firestore.v1.IBeginTransactionRequest | undefined, {} | undefined]>;
beginTransaction(request: protos.google.firestore.v1.IBeginTransactionRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1.IBeginTransactionResponse, protos.google.firestore.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void;
beginTransaction(request: protos.google.firestore.v1.IBeginTransactionRequest, callback: Callback<protos.google.firestore.v1.IBeginTransactionResponse, protos.google.firestore.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void;
commit(request: protos.google.firestore.v1.ICommitRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1.ICommitResponse, protos.google.firestore.v1.ICommitRequest | undefined, {} | undefined]>;
commit(request: protos.google.firestore.v1.ICommitRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1.ICommitResponse, protos.google.firestore.v1.ICommitRequest | null | undefined, {} | null | undefined>): void;
commit(request: protos.google.firestore.v1.ICommitRequest, callback: Callback<protos.google.firestore.v1.ICommitResponse, protos.google.firestore.v1.ICommitRequest | null | undefined, {} | null | undefined>): void;
rollback(request: protos.google.firestore.v1.IRollbackRequest, options?: gax.CallOptions): Promise<[protos.google.protobuf.IEmpty, protos.google.firestore.v1.IRollbackRequest | undefined, {} | undefined]>;
rollback(request: protos.google.firestore.v1.IRollbackRequest, options: gax.CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.firestore.v1.IRollbackRequest | null | undefined, {} | null | undefined>): void;
rollback(request: protos.google.firestore.v1.IRollbackRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.firestore.v1.IRollbackRequest | null | undefined, {} | null | undefined>): void;
batchWrite(request: protos.google.firestore.v1.IBatchWriteRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1.IBatchWriteResponse, protos.google.firestore.v1.IBatchWriteRequest | undefined, {} | undefined]>;
batchWrite(request: protos.google.firestore.v1.IBatchWriteRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1.IBatchWriteResponse, protos.google.firestore.v1.IBatchWriteRequest | null | undefined, {} | null | undefined>): void;
batchWrite(request: protos.google.firestore.v1.IBatchWriteRequest, callback: Callback<protos.google.firestore.v1.IBatchWriteResponse, protos.google.firestore.v1.IBatchWriteRequest | null | undefined, {} | null | undefined>): void;
createDocument(request: protos.google.firestore.v1.ICreateDocumentRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1.IDocument, protos.google.firestore.v1.ICreateDocumentRequest | undefined, {} | undefined]>;
createDocument(request: protos.google.firestore.v1.ICreateDocumentRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1.IDocument, protos.google.firestore.v1.ICreateDocumentRequest | null | undefined, {} | null | undefined>): void;
createDocument(request: protos.google.firestore.v1.ICreateDocumentRequest, callback: Callback<protos.google.firestore.v1.IDocument, protos.google.firestore.v1.ICreateDocumentRequest | null | undefined, {} | null | undefined>): void;
/**

@@ -138,3 +150,3 @@ * Gets multiple documents.

* Reads documents as they were at the given time.
* This may not be older than 60 seconds.
* This may not be older than 270 seconds.
* @param {object} [options]

@@ -145,3 +157,3 @@ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.

*/
batchGetDocuments(request?: protosTypes.google.firestore.v1.IBatchGetDocumentsRequest, options?: gax.CallOptions): gax.CancellableStream;
batchGetDocuments(request?: protos.google.firestore.v1.IBatchGetDocumentsRequest, options?: gax.CallOptions): gax.CancellableStream;
/**

@@ -170,3 +182,3 @@ * Runs a query.

* Reads documents as they were at the given time.
* This may not be older than 60 seconds.
* This may not be older than 270 seconds.
* @param {object} [options]

@@ -177,3 +189,3 @@ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.

*/
runQuery(request?: protosTypes.google.firestore.v1.IRunQueryRequest, options?: gax.CallOptions): gax.CancellableStream;
runQuery(request?: protos.google.firestore.v1.IRunQueryRequest, options?: gax.CallOptions): gax.CancellableStream;
/**

@@ -201,4 +213,5 @@ * Streams batches of document updates and deletes, in order.

listen(options?: gax.CallOptions): gax.CancellableStream;
listDocuments(request: protosTypes.google.firestore.v1.IListDocumentsRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1.IDocument[], protosTypes.google.firestore.v1.IListDocumentsRequest | null, protosTypes.google.firestore.v1.IListDocumentsResponse]>;
listDocuments(request: protosTypes.google.firestore.v1.IListDocumentsRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1.IDocument[], protosTypes.google.firestore.v1.IListDocumentsRequest | null, protosTypes.google.firestore.v1.IListDocumentsResponse>): void;
listDocuments(request: protos.google.firestore.v1.IListDocumentsRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1.IDocument[], protos.google.firestore.v1.IListDocumentsRequest | null, protos.google.firestore.v1.IListDocumentsResponse]>;
listDocuments(request: protos.google.firestore.v1.IListDocumentsRequest, options: gax.CallOptions, callback: PaginationCallback<protos.google.firestore.v1.IListDocumentsRequest, protos.google.firestore.v1.IListDocumentsResponse | null | undefined, protos.google.firestore.v1.IDocument>): void;
listDocuments(request: protos.google.firestore.v1.IListDocumentsRequest, callback: PaginationCallback<protos.google.firestore.v1.IListDocumentsRequest, protos.google.firestore.v1.IListDocumentsResponse | null | undefined, protos.google.firestore.v1.IDocument>): void;
/**

@@ -244,3 +257,3 @@ * Equivalent to {@link listDocuments}, but returns a NodeJS Stream object.

* Reads documents as they were at the given time.
* This may not be older than 60 seconds.
* This may not be older than 270 seconds.
* @param {boolean} request.showMissing

@@ -259,6 +272,171 @@ * If the list should show missing documents. A missing document is a

*/
listDocumentsStream(request?: protosTypes.google.firestore.v1.IListDocumentsRequest, options?: gax.CallOptions): Transform;
listCollectionIds(request: protosTypes.google.firestore.v1.IListCollectionIdsRequest, options?: gax.CallOptions): Promise<[string[], protosTypes.google.firestore.v1.IListCollectionIdsRequest | null, protosTypes.google.firestore.v1.IListCollectionIdsResponse]>;
listCollectionIds(request: protosTypes.google.firestore.v1.IListCollectionIdsRequest, options: gax.CallOptions, callback: Callback<string[], protosTypes.google.firestore.v1.IListCollectionIdsRequest | null, protosTypes.google.firestore.v1.IListCollectionIdsResponse>): void;
listDocumentsStream(request?: protos.google.firestore.v1.IListDocumentsRequest, options?: gax.CallOptions): Transform;
/**
* Equivalent to {@link listDocuments}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name. In the format:
* `projects/{project_id}/databases/{database_id}/documents` or
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
* For example:
* `projects/my-project/databases/my-database/documents` or
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
* @param {string} request.collectionId
* Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
* or `messages`.
* @param {number} request.pageSize
* The maximum number of documents to return.
* @param {string} request.pageToken
* The `next_page_token` value returned from a previous List request, if any.
* @param {string} request.orderBy
* The order to sort results by. For example: `priority desc, name`.
* @param {google.firestore.v1.DocumentMask} request.mask
* The fields to return. If not set, returns all fields.
*
* If a document has a field that is not present in this mask, that field
* will not be returned in the response.
* @param {Buffer} request.transaction
* Reads documents in a transaction.
* @param {google.protobuf.Timestamp} request.readTime
* Reads documents as they were at the given time.
* This may not be older than 270 seconds.
* @param {boolean} request.showMissing
* If the list should show missing documents. A missing document is a
* document that does not exist but has sub-documents. These documents will
* be returned with a key but will not have fields, {@link google.firestore.v1.Document.create_time|Document.create_time},
* or {@link google.firestore.v1.Document.update_time|Document.update_time} set.
*
* Requests with `show_missing` may not specify `where` or
* `order_by`.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listDocumentsAsync(request?: protos.google.firestore.v1.IListDocumentsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.firestore.v1.IDocument>;
partitionQuery(request: protos.google.firestore.v1.IPartitionQueryRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1.ICursor[], protos.google.firestore.v1.IPartitionQueryRequest | null, protos.google.firestore.v1.IPartitionQueryResponse]>;
partitionQuery(request: protos.google.firestore.v1.IPartitionQueryRequest, options: gax.CallOptions, callback: PaginationCallback<protos.google.firestore.v1.IPartitionQueryRequest, protos.google.firestore.v1.IPartitionQueryResponse | null | undefined, protos.google.firestore.v1.ICursor>): void;
partitionQuery(request: protos.google.firestore.v1.IPartitionQueryRequest, callback: PaginationCallback<protos.google.firestore.v1.IPartitionQueryRequest, protos.google.firestore.v1.IPartitionQueryResponse | null | undefined, protos.google.firestore.v1.ICursor>): void;
/**
* Equivalent to {@link partitionQuery}, but returns a NodeJS Stream object.
*
* This fetches the paged responses for {@link partitionQuery} continuously
* and invokes the callback registered for 'data' event for each element in the
* responses.
*
* The returned object has 'end' method when no more elements are required.
*
* autoPaginate option will be ignored.
*
* @see {@link https://nodejs.org/api/stream.html}
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name. In the format:
* `projects/{project_id}/databases/{database_id}/documents`.
* Document resource names are not supported; only database resource names
* can be specified.
* @param {google.firestore.v1.StructuredQuery} request.structuredQuery
* A structured query.
* Filters, order bys, limits, offsets, and start/end cursors are not
* supported.
* @param {number} request.partitionCount
* The desired maximum number of partition points.
* The partitions may be returned across multiple pages of results.
* The number must be strictly positive. The actual number of partitions
* returned may be fewer.
*
* For example, this may be set to one fewer than the number of parallel
* queries to be run, or in running a data pipeline job, one fewer than the
* number of workers or compute instances available.
* @param {string} request.pageToken
* The `next_page_token` value returned from a previous call to
* PartitionQuery that may be used to get an additional set of results.
* There are no ordering guarantees between sets of results. Thus, using
* multiple sets of results will require merging the different result sets.
*
* For example, two subsequent calls using a page_token may return:
*
* * cursor B, cursor M, cursor Q
* * cursor A, cursor U, cursor W
*
* To obtain a complete result set ordered with respect to the results of the
* query supplied to PartitionQuery, the results sets should be merged:
* cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
* @param {number} request.pageSize
* The maximum number of partitions to return in this call, subject to
* `partition_count`.
*
* For example, if `partition_count` = 10 and `page_size` = 8, the first call
* to PartitionQuery will return up to 8 partitions and a `next_page_token`
* if more results exist. A second call to PartitionQuery will return up to
* 2 partitions, to complete the total of 10 specified in `partition_count`.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Stream}
* An object stream which emits an object representing [Cursor]{@link google.firestore.v1.Cursor} on 'data' event.
*/
partitionQueryStream(request?: protos.google.firestore.v1.IPartitionQueryRequest, options?: gax.CallOptions): Transform;
/**
* Equivalent to {@link partitionQuery}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name. In the format:
* `projects/{project_id}/databases/{database_id}/documents`.
* Document resource names are not supported; only database resource names
* can be specified.
* @param {google.firestore.v1.StructuredQuery} request.structuredQuery
* A structured query.
* Filters, order bys, limits, offsets, and start/end cursors are not
* supported.
* @param {number} request.partitionCount
* The desired maximum number of partition points.
* The partitions may be returned across multiple pages of results.
* The number must be strictly positive. The actual number of partitions
* returned may be fewer.
*
* For example, this may be set to one fewer than the number of parallel
* queries to be run, or in running a data pipeline job, one fewer than the
* number of workers or compute instances available.
* @param {string} request.pageToken
* The `next_page_token` value returned from a previous call to
* PartitionQuery that may be used to get an additional set of results.
* There are no ordering guarantees between sets of results. Thus, using
* multiple sets of results will require merging the different result sets.
*
* For example, two subsequent calls using a page_token may return:
*
* * cursor B, cursor M, cursor Q
* * cursor A, cursor U, cursor W
*
* To obtain a complete result set ordered with respect to the results of the
* query supplied to PartitionQuery, the results sets should be merged:
* cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
* @param {number} request.pageSize
* The maximum number of partitions to return in this call, subject to
* `partition_count`.
*
* For example, if `partition_count` = 10 and `page_size` = 8, the first call
* to PartitionQuery will return up to 8 partitions and a `next_page_token`
* if more results exist. A second call to PartitionQuery will return up to
* 2 partitions, to complete the total of 10 specified in `partition_count`.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
partitionQueryAsync(request?: protos.google.firestore.v1.IPartitionQueryRequest, options?: gax.CallOptions): AsyncIterable<protos.google.firestore.v1.ICursor>;
listCollectionIds(request: protos.google.firestore.v1.IListCollectionIdsRequest, options?: gax.CallOptions): Promise<[string[], protos.google.firestore.v1.IListCollectionIdsRequest | null, protos.google.firestore.v1.IListCollectionIdsResponse]>;
listCollectionIds(request: protos.google.firestore.v1.IListCollectionIdsRequest, options: gax.CallOptions, callback: PaginationCallback<protos.google.firestore.v1.IListCollectionIdsRequest, protos.google.firestore.v1.IListCollectionIdsResponse | null | undefined, string>): void;
listCollectionIds(request: protos.google.firestore.v1.IListCollectionIdsRequest, callback: PaginationCallback<protos.google.firestore.v1.IListCollectionIdsRequest, protos.google.firestore.v1.IListCollectionIdsResponse | null | undefined, string>): void;
/**
* Equivalent to {@link listCollectionIds}, but returns a NodeJS Stream object.

@@ -293,4 +471,27 @@ *

*/
listCollectionIdsStream(request?: protosTypes.google.firestore.v1.IListCollectionIdsRequest, options?: gax.CallOptions): Transform;
listCollectionIdsStream(request?: protos.google.firestore.v1.IListCollectionIdsRequest, options?: gax.CallOptions): Transform;
/**
* Equivalent to {@link listCollectionIds}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent document. In the format:
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
* For example:
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
* @param {number} request.pageSize
* The maximum number of results to return.
* @param {string} request.pageToken
* A page token. Must be a value from
* {@link google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listCollectionIdsAsync(request?: protos.google.firestore.v1.IListCollectionIdsRequest, options?: gax.CallOptions): AsyncIterable<string>;
/**
* Terminate the GRPC channel and close the client.

@@ -297,0 +498,0 @@ *

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

constructor(opts) {
this._descriptors = {
this._terminated = false;
this.descriptors = {
page: {},

@@ -70,3 +71,2 @@ stream: {},

};
this._terminated = false;
// Ensure that options include the service address and port.

@@ -85,11 +85,14 @@ const staticMembers = this.constructor;

opts.port = opts.port || port;
// users can override the config from client side, like retry codes name.
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
// The way to override client config for Showcase API:
//
// const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};
const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
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.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the FirestoreClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;
// Create a `gaxGrpc` object, with any grpc-specific options

@@ -121,8 +124,12 @@ // sent to the client.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
this._protos = this._gaxGrpc.loadProto(opts.fallback
? // eslint-disable-next-line @typescript-eslint/no-var-requires
require('../../protos/protos.json')
: nodejsProtoPath);
// Some of the methods on this service return "paged" results,
// (e.g. 50 results at a time, with tokens to get subsequent
// pages). Denote the keys used for pagination and results.
this._descriptors.page = {
this.descriptors.page = {
listDocuments: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents'),
partitionQuery: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'partitions'),
listCollectionIds: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'collectionIds'),

@@ -132,3 +139,3 @@ };

// Provide descriptors for these.
this._descriptors.stream = {
this.descriptors.stream = {
batchGetDocuments: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING),

@@ -144,3 +151,3 @@ runQuery: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING),

// merely providing the destination and request information.
this._innerApiCalls = {};
this.innerApiCalls = {};
}

@@ -167,3 +174,3 @@ /**

? this._protos.lookupService('google.firestore.v1.Firestore')
: // tslint:disable-next-line no-any
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
this._protos.google.firestore.v1.Firestore, this._opts);

@@ -182,11 +189,13 @@ // Iterate over each of the methods that the service provides

'runQuery',
'partitionQuery',
'write',
'listen',
'listCollectionIds',
'batchWrite',
'createDocument',
];
for (const methodName of firestoreStubMethods) {
const innerCallPromise = this.firestoreStub.then(stub => (...args) => {
const callPromise = this.firestoreStub.then(stub => (...args) => {
if (this._terminated) {
return Promise.reject(new Error('The client has already been closed.'));
return Promise.reject('The client has already been closed.');
}

@@ -198,8 +207,6 @@ const func = stub[methodName];

});
const apiCall = this._gaxModule.createApiCall(innerCallPromise, this._defaults[methodName], this._descriptors.page[methodName] ||
this._descriptors.stream[methodName] ||
this._descriptors.longrunning[methodName]);
this._innerApiCalls[methodName] = (argument, callOptions, callback) => {
return apiCall(argument, callOptions, callback);
};
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], this.descriptors.page[methodName] ||
this.descriptors.stream[methodName] ||
this.descriptors.longrunning[methodName]);
this.innerApiCalls[methodName] = apiCall;
}

@@ -266,3 +273,3 @@ return this.firestoreStub;

* Reads the version of the document at the given time.
* This may not be older than 60 seconds.
* This may not be older than 270 seconds.
* @param {object} [options]

@@ -291,3 +298,3 @@ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.

this.initialize();
return this._innerApiCalls.getDocument(request, options, callback);
return this.innerApiCalls.getDocument(request, options, callback);
}

@@ -341,3 +348,3 @@ /**

this.initialize();
return this._innerApiCalls.updateDocument(request, options, callback);
return this.innerApiCalls.updateDocument(request, options, callback);
}

@@ -378,3 +385,3 @@ /**

this.initialize();
return this._innerApiCalls.deleteDocument(request, options, callback);
return this.innerApiCalls.deleteDocument(request, options, callback);
}

@@ -415,3 +422,3 @@ /**

this.initialize();
return this._innerApiCalls.beginTransaction(request, options, callback);
return this.innerApiCalls.beginTransaction(request, options, callback);
}

@@ -455,3 +462,3 @@ /**

this.initialize();
return this._innerApiCalls.commit(request, options, callback);
return this.innerApiCalls.commit(request, options, callback);
}

@@ -491,5 +498,54 @@ /**

this.initialize();
return this._innerApiCalls.rollback(request, options, callback);
return this.innerApiCalls.rollback(request, options, callback);
}
/**
* Applies a batch of write operations.
*
* The BatchWrite method does not apply the write operations atomically
* and can apply them out of order. Method does not allow more than one write
* per document. Each write succeeds or fails independently. See the
* {@link google.firestore.v1.BatchWriteResponse|BatchWriteResponse} for the success status of each write.
*
* If you require an atomically applied set of writes, use
* {@link google.firestore.v1.Firestore.Commit|Commit} instead.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.database
* Required. The database name. In the format:
* `projects/{project_id}/databases/{database_id}`.
* @param {number[]} request.writes
* The writes to apply.
*
* Method does not apply writes atomically and does not guarantee ordering.
* Each write succeeds or fails independently. You cannot write to the same
* document more than once per request.
* @param {number[]} request.labels
* Labels associated with this batch write.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [BatchWriteResponse]{@link google.firestore.v1.BatchWriteResponse}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
batchWrite(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({
database: request.database || '',
});
this.initialize();
return this.innerApiCalls.batchWrite(request, options, callback);
}
/**
* Creates a new document.

@@ -539,3 +595,3 @@ *

this.initialize();
return this._innerApiCalls.createDocument(request, options, callback);
return this.innerApiCalls.createDocument(request, options, callback);
}

@@ -572,3 +628,3 @@ /**

* Reads documents as they were at the given time.
* This may not be older than 60 seconds.
* This may not be older than 270 seconds.
* @param {object} [options]

@@ -588,3 +644,3 @@ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.

this.initialize();
return this._innerApiCalls.batchGetDocuments(request, options);
return this.innerApiCalls.batchGetDocuments(request, options);
}

@@ -614,3 +670,3 @@ /**

* Reads documents as they were at the given time.
* This may not be older than 60 seconds.
* This may not be older than 270 seconds.
* @param {object} [options]

@@ -630,3 +686,3 @@ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.

this.initialize();
return this._innerApiCalls.runQuery(request, options);
return this.innerApiCalls.runQuery(request, options);
}

@@ -645,3 +701,3 @@ /**

this.initialize();
return this._innerApiCalls.write(options);
return this.innerApiCalls.write({}, options);
}

@@ -660,3 +716,3 @@ /**

this.initialize();
return this._innerApiCalls.listen({}, options);
return this.innerApiCalls.listen({}, options);
}

@@ -693,3 +749,3 @@ /**

* Reads documents as they were at the given time.
* This may not be older than 60 seconds.
* This may not be older than 270 seconds.
* @param {boolean} request.showMissing

@@ -738,3 +794,3 @@ * If the list should show missing documents. A missing document is a

this.initialize();
return this._innerApiCalls.listDocuments(request, options, callback);
return this.innerApiCalls.listDocuments(request, options, callback);
}

@@ -781,3 +837,3 @@ /**

* Reads documents as they were at the given time.
* This may not be older than 60 seconds.
* This may not be older than 270 seconds.
* @param {boolean} request.showMissing

@@ -806,5 +862,285 @@ * If the list should show missing documents. A missing document is a

this.initialize();
return this._descriptors.page.listDocuments.createStream(this._innerApiCalls.listDocuments, request, callSettings);
return this.descriptors.page.listDocuments.createStream(this.innerApiCalls.listDocuments, request, callSettings);
}
/**
* Equivalent to {@link listDocuments}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name. In the format:
* `projects/{project_id}/databases/{database_id}/documents` or
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
* For example:
* `projects/my-project/databases/my-database/documents` or
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
* @param {string} request.collectionId
* Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
* or `messages`.
* @param {number} request.pageSize
* The maximum number of documents to return.
* @param {string} request.pageToken
* The `next_page_token` value returned from a previous List request, if any.
* @param {string} request.orderBy
* The order to sort results by. For example: `priority desc, name`.
* @param {google.firestore.v1.DocumentMask} request.mask
* The fields to return. If not set, returns all fields.
*
* If a document has a field that is not present in this mask, that field
* will not be returned in the response.
* @param {Buffer} request.transaction
* Reads documents in a transaction.
* @param {google.protobuf.Timestamp} request.readTime
* Reads documents as they were at the given time.
* This may not be older than 270 seconds.
* @param {boolean} request.showMissing
* If the list should show missing documents. A missing document is a
* document that does not exist but has sub-documents. These documents will
* be returned with a key but will not have fields, {@link google.firestore.v1.Document.create_time|Document.create_time},
* or {@link google.firestore.v1.Document.update_time|Document.update_time} set.
*
* Requests with `show_missing` may not specify `where` or
* `order_by`.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listDocumentsAsync(request, options) {
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listDocuments.asyncIterate(this.innerApiCalls['listDocuments'], request, callSettings);
}
/**
* Partitions a query by returning partition cursors that can be used to run
* the query in parallel. The returned partition cursors are split points that
* can be used by RunQuery as starting/end points for the query results.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name. In the format:
* `projects/{project_id}/databases/{database_id}/documents`.
* Document resource names are not supported; only database resource names
* can be specified.
* @param {google.firestore.v1.StructuredQuery} request.structuredQuery
* A structured query.
* Filters, order bys, limits, offsets, and start/end cursors are not
* supported.
* @param {number} request.partitionCount
* The desired maximum number of partition points.
* The partitions may be returned across multiple pages of results.
* The number must be strictly positive. The actual number of partitions
* returned may be fewer.
*
* For example, this may be set to one fewer than the number of parallel
* queries to be run, or in running a data pipeline job, one fewer than the
* number of workers or compute instances available.
* @param {string} request.pageToken
* The `next_page_token` value returned from a previous call to
* PartitionQuery that may be used to get an additional set of results.
* There are no ordering guarantees between sets of results. Thus, using
* multiple sets of results will require merging the different result sets.
*
* For example, two subsequent calls using a page_token may return:
*
* * cursor B, cursor M, cursor Q
* * cursor A, cursor U, cursor W
*
* To obtain a complete result set ordered with respect to the results of the
* query supplied to PartitionQuery, the results sets should be merged:
* cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
* @param {number} request.pageSize
* The maximum number of partitions to return in this call, subject to
* `partition_count`.
*
* For example, if `partition_count` = 10 and `page_size` = 8, the first call
* to PartitionQuery will return up to 8 partitions and a `next_page_token`
* if more results exist. A second call to PartitionQuery will return up to
* 2 partitions, to complete the total of 10 specified in `partition_count`.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is Array of [Cursor]{@link google.firestore.v1.Cursor}.
* The client library support auto-pagination by default: it will call the API as many
* times as needed and will merge results from all the pages into this array.
*
* When autoPaginate: false is specified through options, the array has three elements.
* The first element is Array of [Cursor]{@link google.firestore.v1.Cursor} that corresponds to
* the one page received from the API server.
* If the second element is not null it contains the request object of type [PartitionQueryRequest]{@link google.firestore.v1.PartitionQueryRequest}
* that can be used to obtain the next page of the results.
* If it is null, the next page does not exist.
* The third element contains the raw response received from the API server. Its type is
* [PartitionQueryResponse]{@link google.firestore.v1.PartitionQueryResponse}.
*
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
partitionQuery(request, optionsOrCallback, callback) {
request = request || {};
let options;
if (typeof optionsOrCallback === 'function' && callback === undefined) {
callback = optionsOrCallback;
options = {};
}
else {
options = optionsOrCallback;
}
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
this.initialize();
return this.innerApiCalls.partitionQuery(request, options, callback);
}
/**
* Equivalent to {@link partitionQuery}, but returns a NodeJS Stream object.
*
* This fetches the paged responses for {@link partitionQuery} continuously
* and invokes the callback registered for 'data' event for each element in the
* responses.
*
* The returned object has 'end' method when no more elements are required.
*
* autoPaginate option will be ignored.
*
* @see {@link https://nodejs.org/api/stream.html}
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name. In the format:
* `projects/{project_id}/databases/{database_id}/documents`.
* Document resource names are not supported; only database resource names
* can be specified.
* @param {google.firestore.v1.StructuredQuery} request.structuredQuery
* A structured query.
* Filters, order bys, limits, offsets, and start/end cursors are not
* supported.
* @param {number} request.partitionCount
* The desired maximum number of partition points.
* The partitions may be returned across multiple pages of results.
* The number must be strictly positive. The actual number of partitions
* returned may be fewer.
*
* For example, this may be set to one fewer than the number of parallel
* queries to be run, or in running a data pipeline job, one fewer than the
* number of workers or compute instances available.
* @param {string} request.pageToken
* The `next_page_token` value returned from a previous call to
* PartitionQuery that may be used to get an additional set of results.
* There are no ordering guarantees between sets of results. Thus, using
* multiple sets of results will require merging the different result sets.
*
* For example, two subsequent calls using a page_token may return:
*
* * cursor B, cursor M, cursor Q
* * cursor A, cursor U, cursor W
*
* To obtain a complete result set ordered with respect to the results of the
* query supplied to PartitionQuery, the results sets should be merged:
* cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
* @param {number} request.pageSize
* The maximum number of partitions to return in this call, subject to
* `partition_count`.
*
* For example, if `partition_count` = 10 and `page_size` = 8, the first call
* to PartitionQuery will return up to 8 partitions and a `next_page_token`
* if more results exist. A second call to PartitionQuery will return up to
* 2 partitions, to complete the total of 10 specified in `partition_count`.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Stream}
* An object stream which emits an object representing [Cursor]{@link google.firestore.v1.Cursor} on 'data' event.
*/
partitionQueryStream(request, options) {
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.partitionQuery.createStream(this.innerApiCalls.partitionQuery, request, callSettings);
}
/**
* Equivalent to {@link partitionQuery}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name. In the format:
* `projects/{project_id}/databases/{database_id}/documents`.
* Document resource names are not supported; only database resource names
* can be specified.
* @param {google.firestore.v1.StructuredQuery} request.structuredQuery
* A structured query.
* Filters, order bys, limits, offsets, and start/end cursors are not
* supported.
* @param {number} request.partitionCount
* The desired maximum number of partition points.
* The partitions may be returned across multiple pages of results.
* The number must be strictly positive. The actual number of partitions
* returned may be fewer.
*
* For example, this may be set to one fewer than the number of parallel
* queries to be run, or in running a data pipeline job, one fewer than the
* number of workers or compute instances available.
* @param {string} request.pageToken
* The `next_page_token` value returned from a previous call to
* PartitionQuery that may be used to get an additional set of results.
* There are no ordering guarantees between sets of results. Thus, using
* multiple sets of results will require merging the different result sets.
*
* For example, two subsequent calls using a page_token may return:
*
* * cursor B, cursor M, cursor Q
* * cursor A, cursor U, cursor W
*
* To obtain a complete result set ordered with respect to the results of the
* query supplied to PartitionQuery, the results sets should be merged:
* cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
* @param {number} request.pageSize
* The maximum number of partitions to return in this call, subject to
* `partition_count`.
*
* For example, if `partition_count` = 10 and `page_size` = 8, the first call
* to PartitionQuery will return up to 8 partitions and a `next_page_token`
* if more results exist. A second call to PartitionQuery will return up to
* 2 partitions, to complete the total of 10 specified in `partition_count`.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
partitionQueryAsync(request, options) {
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.partitionQuery.asyncIterate(this.innerApiCalls['partitionQuery'], request, callSettings);
}
/**
* Lists all the collection IDs underneath a document.

@@ -859,3 +1195,3 @@ *

this.initialize();
return this._innerApiCalls.listCollectionIds(request, options, callback);
return this.innerApiCalls.listCollectionIds(request, options, callback);
}

@@ -902,5 +1238,40 @@ /**

this.initialize();
return this._descriptors.page.listCollectionIds.createStream(this._innerApiCalls.listCollectionIds, request, callSettings);
return this.descriptors.page.listCollectionIds.createStream(this.innerApiCalls.listCollectionIds, request, callSettings);
}
/**
* Equivalent to {@link listCollectionIds}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent document. In the format:
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
* For example:
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
* @param {number} request.pageSize
* The maximum number of results to return.
* @param {string} request.pageToken
* A page token. Must be a value from
* {@link google.firestore.v1.ListCollectionIdsResponse|ListCollectionIdsResponse}.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listCollectionIdsAsync(request, options) {
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listCollectionIds.asyncIterate(this.innerApiCalls['listCollectionIds'], request, callSettings);
}
/**
* Terminate the GRPC channel and close the client.

@@ -907,0 +1278,0 @@ *

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

@@ -24,7 +24,6 @@ * The Cloud Firestore service.

* @class
* @deprecated Use v1/firestore_client instead.
* @memberof v1beta1
*/
export declare class FirestoreClient {
private _descriptors;
private _innerApiCalls;
private _terminated;

@@ -37,2 +36,6 @@ private _opts;

auth: gax.GoogleAuth;
descriptors: Descriptors;
innerApiCalls: {
[name: string]: Function;
};
firestoreStub?: Promise<{

@@ -101,16 +104,23 @@ [name: string]: Function;

getProjectId(callback: Callback<string, undefined, undefined>): void;
getDocument(request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1beta1.IDocument, protosTypes.google.firestore.v1beta1.IGetDocumentRequest | undefined, {} | undefined]>;
getDocument(request: protosTypes.google.firestore.v1beta1.IGetDocumentRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1beta1.IDocument, protosTypes.google.firestore.v1beta1.IGetDocumentRequest | undefined, {} | undefined>): void;
createDocument(request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1beta1.IDocument, protosTypes.google.firestore.v1beta1.ICreateDocumentRequest | undefined, {} | undefined]>;
createDocument(request: protosTypes.google.firestore.v1beta1.ICreateDocumentRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1beta1.IDocument, protosTypes.google.firestore.v1beta1.ICreateDocumentRequest | undefined, {} | undefined>): void;
updateDocument(request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1beta1.IDocument, protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, {} | undefined]>;
updateDocument(request: protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1beta1.IDocument, protosTypes.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, {} | undefined>): void;
deleteDocument(request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest, options?: gax.CallOptions): Promise<[protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, {} | undefined]>;
deleteDocument(request: protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, {} | undefined>): void;
beginTransaction(request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1beta1.IBeginTransactionResponse, protosTypes.google.firestore.v1beta1.IBeginTransactionRequest | undefined, {} | undefined]>;
beginTransaction(request: protosTypes.google.firestore.v1beta1.IBeginTransactionRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1beta1.IBeginTransactionResponse, protosTypes.google.firestore.v1beta1.IBeginTransactionRequest | undefined, {} | undefined>): void;
commit(request: protosTypes.google.firestore.v1beta1.ICommitRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1beta1.ICommitResponse, protosTypes.google.firestore.v1beta1.ICommitRequest | undefined, {} | undefined]>;
commit(request: protosTypes.google.firestore.v1beta1.ICommitRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1beta1.ICommitResponse, protosTypes.google.firestore.v1beta1.ICommitRequest | undefined, {} | undefined>): void;
rollback(request: protosTypes.google.firestore.v1beta1.IRollbackRequest, options?: gax.CallOptions): Promise<[protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.v1beta1.IRollbackRequest | undefined, {} | undefined]>;
rollback(request: protosTypes.google.firestore.v1beta1.IRollbackRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.protobuf.IEmpty, protosTypes.google.firestore.v1beta1.IRollbackRequest | undefined, {} | undefined>): void;
getDocument(request: protos.google.firestore.v1beta1.IGetDocumentRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.IGetDocumentRequest | undefined, {} | undefined]>;
getDocument(request: protos.google.firestore.v1beta1.IGetDocumentRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.IGetDocumentRequest | null | undefined, {} | null | undefined>): void;
getDocument(request: protos.google.firestore.v1beta1.IGetDocumentRequest, callback: Callback<protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.IGetDocumentRequest | null | undefined, {} | null | undefined>): void;
createDocument(request: protos.google.firestore.v1beta1.ICreateDocumentRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.ICreateDocumentRequest | undefined, {} | undefined]>;
createDocument(request: protos.google.firestore.v1beta1.ICreateDocumentRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.ICreateDocumentRequest | null | undefined, {} | null | undefined>): void;
createDocument(request: protos.google.firestore.v1beta1.ICreateDocumentRequest, callback: Callback<protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.ICreateDocumentRequest | null | undefined, {} | null | undefined>): void;
updateDocument(request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.IUpdateDocumentRequest | undefined, {} | undefined]>;
updateDocument(request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.IUpdateDocumentRequest | null | undefined, {} | null | undefined>): void;
updateDocument(request: protos.google.firestore.v1beta1.IUpdateDocumentRequest, callback: Callback<protos.google.firestore.v1beta1.IDocument, protos.google.firestore.v1beta1.IUpdateDocumentRequest | null | undefined, {} | null | undefined>): void;
deleteDocument(request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, options?: gax.CallOptions): Promise<[protos.google.protobuf.IEmpty, protos.google.firestore.v1beta1.IDeleteDocumentRequest | undefined, {} | undefined]>;
deleteDocument(request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, options: gax.CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.firestore.v1beta1.IDeleteDocumentRequest | null | undefined, {} | null | undefined>): void;
deleteDocument(request: protos.google.firestore.v1beta1.IDeleteDocumentRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.firestore.v1beta1.IDeleteDocumentRequest | null | undefined, {} | null | undefined>): void;
beginTransaction(request: protos.google.firestore.v1beta1.IBeginTransactionRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1beta1.IBeginTransactionResponse, protos.google.firestore.v1beta1.IBeginTransactionRequest | undefined, {} | undefined]>;
beginTransaction(request: protos.google.firestore.v1beta1.IBeginTransactionRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1beta1.IBeginTransactionResponse, protos.google.firestore.v1beta1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void;
beginTransaction(request: protos.google.firestore.v1beta1.IBeginTransactionRequest, callback: Callback<protos.google.firestore.v1beta1.IBeginTransactionResponse, protos.google.firestore.v1beta1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void;
commit(request: protos.google.firestore.v1beta1.ICommitRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1beta1.ICommitResponse, protos.google.firestore.v1beta1.ICommitRequest | undefined, {} | undefined]>;
commit(request: protos.google.firestore.v1beta1.ICommitRequest, options: gax.CallOptions, callback: Callback<protos.google.firestore.v1beta1.ICommitResponse, protos.google.firestore.v1beta1.ICommitRequest | null | undefined, {} | null | undefined>): void;
commit(request: protos.google.firestore.v1beta1.ICommitRequest, callback: Callback<protos.google.firestore.v1beta1.ICommitResponse, protos.google.firestore.v1beta1.ICommitRequest | null | undefined, {} | null | undefined>): void;
rollback(request: protos.google.firestore.v1beta1.IRollbackRequest, options?: gax.CallOptions): Promise<[protos.google.protobuf.IEmpty, protos.google.firestore.v1beta1.IRollbackRequest | undefined, {} | undefined]>;
rollback(request: protos.google.firestore.v1beta1.IRollbackRequest, options: gax.CallOptions, callback: Callback<protos.google.protobuf.IEmpty, protos.google.firestore.v1beta1.IRollbackRequest | null | undefined, {} | null | undefined>): void;
rollback(request: protos.google.firestore.v1beta1.IRollbackRequest, callback: Callback<protos.google.protobuf.IEmpty, protos.google.firestore.v1beta1.IRollbackRequest | null | undefined, {} | null | undefined>): void;
/**

@@ -152,3 +162,3 @@ * Gets multiple documents.

*/
batchGetDocuments(request?: protosTypes.google.firestore.v1beta1.IBatchGetDocumentsRequest, options?: gax.CallOptions): gax.CancellableStream;
batchGetDocuments(request?: protos.google.firestore.v1beta1.IBatchGetDocumentsRequest, options?: gax.CallOptions): gax.CancellableStream;
/**

@@ -183,3 +193,3 @@ * Runs a query.

*/
runQuery(request?: protosTypes.google.firestore.v1beta1.IRunQueryRequest, options?: gax.CallOptions): gax.CancellableStream;
runQuery(request?: protos.google.firestore.v1beta1.IRunQueryRequest, options?: gax.CallOptions): gax.CancellableStream;
/**

@@ -207,4 +217,5 @@ * Streams batches of document updates and deletes, in order.

listen(options?: gax.CallOptions): gax.CancellableStream;
listDocuments(request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest, options?: gax.CallOptions): Promise<[protosTypes.google.firestore.v1beta1.IDocument[], protosTypes.google.firestore.v1beta1.IListDocumentsRequest | null, protosTypes.google.firestore.v1beta1.IListDocumentsResponse]>;
listDocuments(request: protosTypes.google.firestore.v1beta1.IListDocumentsRequest, options: gax.CallOptions, callback: Callback<protosTypes.google.firestore.v1beta1.IDocument[], protosTypes.google.firestore.v1beta1.IListDocumentsRequest | null, protosTypes.google.firestore.v1beta1.IListDocumentsResponse>): void;
listDocuments(request: protos.google.firestore.v1beta1.IListDocumentsRequest, options?: gax.CallOptions): Promise<[protos.google.firestore.v1beta1.IDocument[], protos.google.firestore.v1beta1.IListDocumentsRequest | null, protos.google.firestore.v1beta1.IListDocumentsResponse]>;
listDocuments(request: protos.google.firestore.v1beta1.IListDocumentsRequest, options: gax.CallOptions, callback: PaginationCallback<protos.google.firestore.v1beta1.IListDocumentsRequest, protos.google.firestore.v1beta1.IListDocumentsResponse | null | undefined, protos.google.firestore.v1beta1.IDocument>): void;
listDocuments(request: protos.google.firestore.v1beta1.IListDocumentsRequest, callback: PaginationCallback<protos.google.firestore.v1beta1.IListDocumentsRequest, protos.google.firestore.v1beta1.IListDocumentsResponse | null | undefined, protos.google.firestore.v1beta1.IDocument>): void;
/**

@@ -264,6 +275,54 @@ * Equivalent to {@link listDocuments}, but returns a NodeJS Stream object.

*/
listDocumentsStream(request?: protosTypes.google.firestore.v1beta1.IListDocumentsRequest, options?: gax.CallOptions): Transform;
listCollectionIds(request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest, options?: gax.CallOptions): Promise<[string[], protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest | null, protosTypes.google.firestore.v1beta1.IListCollectionIdsResponse]>;
listCollectionIds(request: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest, options: gax.CallOptions, callback: Callback<string[], protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest | null, protosTypes.google.firestore.v1beta1.IListCollectionIdsResponse>): void;
listDocumentsStream(request?: protos.google.firestore.v1beta1.IListDocumentsRequest, options?: gax.CallOptions): Transform;
/**
* Equivalent to {@link listDocuments}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name. In the format:
* `projects/{project_id}/databases/{database_id}/documents` or
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
* For example:
* `projects/my-project/databases/my-database/documents` or
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
* @param {string} request.collectionId
* Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
* or `messages`.
* @param {number} request.pageSize
* The maximum number of documents to return.
* @param {string} request.pageToken
* The `next_page_token` value returned from a previous List request, if any.
* @param {string} request.orderBy
* The order to sort results by. For example: `priority desc, name`.
* @param {google.firestore.v1beta1.DocumentMask} request.mask
* The fields to return. If not set, returns all fields.
*
* If a document has a field that is not present in this mask, that field
* will not be returned in the response.
* @param {Buffer} request.transaction
* Reads documents in a transaction.
* @param {google.protobuf.Timestamp} request.readTime
* Reads documents as they were at the given time.
* This may not be older than 60 seconds.
* @param {boolean} request.showMissing
* If the list should show missing documents. A missing document is a
* document that does not exist but has sub-documents. These documents will
* be returned with a key but will not have fields, {@link google.firestore.v1beta1.Document.create_time|Document.create_time},
* or {@link google.firestore.v1beta1.Document.update_time|Document.update_time} set.
*
* Requests with `show_missing` may not specify `where` or
* `order_by`.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listDocumentsAsync(request?: protos.google.firestore.v1beta1.IListDocumentsRequest, options?: gax.CallOptions): AsyncIterable<protos.google.firestore.v1beta1.IDocument>;
listCollectionIds(request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options?: gax.CallOptions): Promise<[string[], protos.google.firestore.v1beta1.IListCollectionIdsRequest | null, protos.google.firestore.v1beta1.IListCollectionIdsResponse]>;
listCollectionIds(request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options: gax.CallOptions, callback: PaginationCallback<protos.google.firestore.v1beta1.IListCollectionIdsRequest, protos.google.firestore.v1beta1.IListCollectionIdsResponse | null | undefined, string>): void;
listCollectionIds(request: protos.google.firestore.v1beta1.IListCollectionIdsRequest, callback: PaginationCallback<protos.google.firestore.v1beta1.IListCollectionIdsRequest, protos.google.firestore.v1beta1.IListCollectionIdsResponse | null | undefined, string>): void;
/**
* Equivalent to {@link listCollectionIds}, but returns a NodeJS Stream object.

@@ -298,4 +357,27 @@ *

*/
listCollectionIdsStream(request?: protosTypes.google.firestore.v1beta1.IListCollectionIdsRequest, options?: gax.CallOptions): Transform;
listCollectionIdsStream(request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options?: gax.CallOptions): Transform;
/**
* Equivalent to {@link listCollectionIds}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent document. In the format:
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
* For example:
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
* @param {number} request.pageSize
* The maximum number of results to return.
* @param {string} request.pageToken
* A page token. Must be a value from
* {@link google.firestore.v1beta1.ListCollectionIdsResponse|ListCollectionIdsResponse}.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listCollectionIdsAsync(request?: protos.google.firestore.v1beta1.IListCollectionIdsRequest, options?: gax.CallOptions): AsyncIterable<string>;
/**
* Terminate the GRPC channel and close the client.

@@ -302,0 +384,0 @@ *

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

const gapicConfig = require("./firestore_client_config.json");
// tslint:disable deprecation
const version = require('../../../package.json').version;

@@ -43,2 +44,3 @@ /**

* @class
* @deprecated Use v1/firestore_client instead.
* @memberof v1beta1

@@ -73,3 +75,4 @@ */

constructor(opts) {
this._descriptors = {
this._terminated = false;
this.descriptors = {
page: {},

@@ -80,3 +83,2 @@ stream: {},

};
this._terminated = false;
// Ensure that options include the service address and port.

@@ -95,11 +97,14 @@ const staticMembers = this.constructor;

opts.port = opts.port || port;
// users can override the config from client side, like retry codes name.
// The detailed structure of the clientConfig can be found here: https://github.com/googleapis/gax-nodejs/blob/master/src/gax.ts#L546
// The way to override client config for Showcase API:
//
// const customConfig = {"interfaces": {"google.showcase.v1beta1.Echo": {"methods": {"Echo": {"retry_codes_name": "idempotent", "retry_params_name": "default"}}}}}
// const showcaseClient = new showcaseClient({ projectId, customConfig });
opts.clientConfig = opts.clientConfig || {};
const isBrowser = typeof window !== 'undefined';
if (isBrowser) {
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.
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
// If we're running in browser, it's OK to omit `fallback` since
// google-gax has `browser` field in its `package.json`.
// For Electron (which does not respect `browser` field),
// pass `{fallback: true}` to the FirestoreClient constructor.
this._gaxModule = opts.fallback ? gax.fallback : gax;
// Create a `gaxGrpc` object, with any grpc-specific options

@@ -131,7 +136,10 @@ // sent to the client.

const nodejsProtoPath = path.join(__dirname, '..', '..', 'protos', 'protos.json');
this._protos = this._gaxGrpc.loadProto(opts.fallback ? require('../../protos/protos.json') : nodejsProtoPath);
this._protos = this._gaxGrpc.loadProto(opts.fallback
? // eslint-disable-next-line @typescript-eslint/no-var-requires
require('../../protos/protos.json')
: nodejsProtoPath);
// Some of the methods on this service return "paged" results,
// (e.g. 50 results at a time, with tokens to get subsequent
// pages). Denote the keys used for pagination and results.
this._descriptors.page = {
this.descriptors.page = {
listDocuments: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'documents'),

@@ -142,3 +150,3 @@ listCollectionIds: new this._gaxModule.PageDescriptor('pageToken', 'nextPageToken', 'collectionIds'),

// Provide descriptors for these.
this._descriptors.stream = {
this.descriptors.stream = {
batchGetDocuments: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING),

@@ -154,3 +162,3 @@ runQuery: new this._gaxModule.StreamDescriptor(gax.StreamType.SERVER_STREAMING),

// merely providing the destination and request information.
this._innerApiCalls = {};
this.innerApiCalls = {};
}

@@ -177,3 +185,3 @@ /**

? this._protos.lookupService('google.firestore.v1beta1.Firestore')
: // tslint:disable-next-line no-any
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
this._protos.google.firestore.v1beta1.Firestore, this._opts);

@@ -198,5 +206,5 @@ // Iterate over each of the methods that the service provides

for (const methodName of firestoreStubMethods) {
const innerCallPromise = this.firestoreStub.then(stub => (...args) => {
const callPromise = this.firestoreStub.then(stub => (...args) => {
if (this._terminated) {
return Promise.reject(new Error('The client has already been closed.'));
return Promise.reject('The client has already been closed.');
}

@@ -208,8 +216,6 @@ const func = stub[methodName];

});
const apiCall = this._gaxModule.createApiCall(innerCallPromise, this._defaults[methodName], this._descriptors.page[methodName] ||
this._descriptors.stream[methodName] ||
this._descriptors.longrunning[methodName]);
this._innerApiCalls[methodName] = (argument, callOptions, callback) => {
return apiCall(argument, callOptions, callback);
};
const apiCall = this._gaxModule.createApiCall(callPromise, this._defaults[methodName], this.descriptors.page[methodName] ||
this.descriptors.stream[methodName] ||
this.descriptors.longrunning[methodName]);
this.innerApiCalls[methodName] = apiCall;
}

@@ -300,3 +306,3 @@ return this.firestoreStub;

this.initialize();
return this._innerApiCalls.getDocument(request, options, callback);
return this.innerApiCalls.getDocument(request, options, callback);
}

@@ -348,3 +354,3 @@ /**

this.initialize();
return this._innerApiCalls.createDocument(request, options, callback);
return this.innerApiCalls.createDocument(request, options, callback);
}

@@ -398,3 +404,3 @@ /**

this.initialize();
return this._innerApiCalls.updateDocument(request, options, callback);
return this.innerApiCalls.updateDocument(request, options, callback);
}

@@ -435,3 +441,3 @@ /**

this.initialize();
return this._innerApiCalls.deleteDocument(request, options, callback);
return this.innerApiCalls.deleteDocument(request, options, callback);
}

@@ -472,3 +478,3 @@ /**

this.initialize();
return this._innerApiCalls.beginTransaction(request, options, callback);
return this.innerApiCalls.beginTransaction(request, options, callback);
}

@@ -512,3 +518,3 @@ /**

this.initialize();
return this._innerApiCalls.commit(request, options, callback);
return this.innerApiCalls.commit(request, options, callback);
}

@@ -548,3 +554,3 @@ /**

this.initialize();
return this._innerApiCalls.rollback(request, options, callback);
return this.innerApiCalls.rollback(request, options, callback);
}

@@ -596,3 +602,3 @@ /**

this.initialize();
return this._innerApiCalls.batchGetDocuments(request, options);
return this.innerApiCalls.batchGetDocuments(request, options);
}

@@ -637,3 +643,3 @@ /**

this.initialize();
return this._innerApiCalls.runQuery(request, options);
return this.innerApiCalls.runQuery(request, options);
}

@@ -652,3 +658,3 @@ /**

this.initialize();
return this._innerApiCalls.write(options);
return this.innerApiCalls.write({}, options);
}

@@ -667,3 +673,3 @@ /**

this.initialize();
return this._innerApiCalls.listen({}, options);
return this.innerApiCalls.listen({}, options);
}

@@ -744,3 +750,3 @@ /**

this.initialize();
return this._innerApiCalls.listDocuments(request, options, callback);
return this.innerApiCalls.listDocuments(request, options, callback);
}

@@ -811,5 +817,64 @@ /**

this.initialize();
return this._descriptors.page.listDocuments.createStream(this._innerApiCalls.listDocuments, request, callSettings);
return this.descriptors.page.listDocuments.createStream(this.innerApiCalls.listDocuments, request, callSettings);
}
/**
* Equivalent to {@link listDocuments}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent resource name. In the format:
* `projects/{project_id}/databases/{database_id}/documents` or
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
* For example:
* `projects/my-project/databases/my-database/documents` or
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
* @param {string} request.collectionId
* Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`
* or `messages`.
* @param {number} request.pageSize
* The maximum number of documents to return.
* @param {string} request.pageToken
* The `next_page_token` value returned from a previous List request, if any.
* @param {string} request.orderBy
* The order to sort results by. For example: `priority desc, name`.
* @param {google.firestore.v1beta1.DocumentMask} request.mask
* The fields to return. If not set, returns all fields.
*
* If a document has a field that is not present in this mask, that field
* will not be returned in the response.
* @param {Buffer} request.transaction
* Reads documents in a transaction.
* @param {google.protobuf.Timestamp} request.readTime
* Reads documents as they were at the given time.
* This may not be older than 60 seconds.
* @param {boolean} request.showMissing
* If the list should show missing documents. A missing document is a
* document that does not exist but has sub-documents. These documents will
* be returned with a key but will not have fields, {@link google.firestore.v1beta1.Document.create_time|Document.create_time},
* or {@link google.firestore.v1beta1.Document.update_time|Document.update_time} set.
*
* Requests with `show_missing` may not specify `where` or
* `order_by`.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listDocumentsAsync(request, options) {
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listDocuments.asyncIterate(this.innerApiCalls['listDocuments'], request, callSettings);
}
/**
* Lists all the collection IDs underneath a document.

@@ -864,3 +929,3 @@ *

this.initialize();
return this._innerApiCalls.listCollectionIds(request, options, callback);
return this.innerApiCalls.listCollectionIds(request, options, callback);
}

@@ -907,5 +972,40 @@ /**

this.initialize();
return this._descriptors.page.listCollectionIds.createStream(this._innerApiCalls.listCollectionIds, request, callSettings);
return this.descriptors.page.listCollectionIds.createStream(this.innerApiCalls.listCollectionIds, request, callSettings);
}
/**
* Equivalent to {@link listCollectionIds}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* Required. The parent document. In the format:
* `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
* For example:
* `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
* @param {number} request.pageSize
* The maximum number of results to return.
* @param {string} request.pageToken
* A page token. Must be a value from
* {@link google.firestore.v1beta1.ListCollectionIdsResponse|ListCollectionIdsResponse}.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listCollectionIdsAsync(request, options) {
request = request || {};
options = options || {};
options.otherArgs = options.otherArgs || {};
options.otherArgs.headers = options.otherArgs.headers || {};
options.otherArgs.headers['x-goog-request-params'] = gax.routingHeader.fromParams({
parent: request.parent || '',
});
options = options || {};
const callSettings = new gax.CallSettings(options);
this.initialize();
return this.descriptors.page.listCollectionIds.asyncIterate(this.innerApiCalls['listCollectionIds'], request, callSettings);
}
/**
* Terminate the GRPC channel and close the client.

@@ -912,0 +1012,0 @@ *

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

Object.defineProperty(exports, "__esModule", { value: true });
// tslint:disable deprecation
const firestore_client_1 = require("./firestore_client");

@@ -22,0 +23,0 @@ exports.FirestoreClient = firestore_client_1.FirestoreClient;

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

*/
import * as firestore from '@google-cloud/firestore';
import { google } from '../protos/firestore_v1_proto_api';

@@ -22,3 +23,2 @@ import { QueryDocumentSnapshot } from './document';

import { Timestamp } from './timestamp';
import { DocumentData, FirestoreDataConverter } from './types';
import api = google.firestore.v1;

@@ -65,4 +65,4 @@ /**

*/
declare abstract class Watch<T = DocumentData> {
readonly _converter: FirestoreDataConverter<T>;
declare abstract class Watch<T = firestore.DocumentData> {
readonly _converter: firestore.FirestoreDataConverter<T>;
protected readonly firestore: Firestore;

@@ -129,3 +129,3 @@ private readonly backoff;

*/
constructor(firestore: Firestore, _converter?: FirestoreDataConverter<T>);
constructor(firestore: Firestore, _converter?: firestore.FirestoreDataConverter<T>);
/** Returns a 'Target' proto denoting the target to listen on. */

@@ -264,3 +264,3 @@ protected abstract getTarget(resumeToken?: Uint8Array): api.ITarget;

*/
export declare class DocumentWatch<T = DocumentData> extends Watch<T> {
export declare class DocumentWatch<T = firestore.DocumentData> extends Watch<T> {
private readonly ref;

@@ -276,6 +276,6 @@ constructor(firestore: Firestore, ref: DocumentReference<T>);

*/
export declare class QueryWatch<T = DocumentData> extends Watch<T> {
export declare class QueryWatch<T = firestore.DocumentData> extends Watch<T> {
private readonly query;
private comparator;
constructor(firestore: Firestore, query: Query<T>, converter?: FirestoreDataConverter<T>);
constructor(firestore: Firestore, query: Query<T>, converter?: firestore.FirestoreDataConverter<T>);
getComparator(): DocumentComparator<T>;

@@ -282,0 +282,0 @@ getTarget(resumeToken?: Uint8Array): google.firestore.v1.ITarget;

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

*/
// tslint:disable-next-line:no-any
const REMOVED = {};

@@ -81,3 +80,3 @@ /*!

*/
constructor(firestore, _converter = types_1.defaultConverter) {
constructor(firestore, _converter = types_1.defaultConverter()) {
this._converter = _converter;

@@ -84,0 +83,0 @@ /**

@@ -16,8 +16,6 @@ /*!

*/
import * as firestore from '@google-cloud/firestore';
import { Firestore } from './index';
import { FieldPath } from './path';
import { DocumentReference } from './reference';
import { Timestamp } from './timestamp';
import { Precondition as PublicPrecondition, SetOptions, UpdateData } from './types';
import { DocumentData } from './types';
import { RequiredArgumentOptions } from './validate';

@@ -31,3 +29,3 @@ import { GoogleError } from 'google-gax';

*/
export declare class WriteResult {
export declare class WriteResult implements firestore.WriteResult {
private readonly _writeTime;

@@ -61,3 +59,3 @@ /**

*/
isEqual(other: WriteResult): boolean;
isEqual(other: firestore.WriteResult): boolean;
}

@@ -81,3 +79,3 @@ /**

*/
export declare class WriteBatch {
export declare class WriteBatch implements firestore.WriteBatch {
private readonly _firestore;

@@ -131,3 +129,3 @@ private readonly _serializer;

*/
create<T>(documentRef: DocumentReference<T>, data: T): WriteBatch;
create<T>(documentRef: firestore.DocumentReference<T>, data: T): WriteBatch;
/**

@@ -156,35 +154,7 @@ * Deletes a document from the database.

*/
delete<T>(documentRef: DocumentReference<T>, precondition?: PublicPrecondition): WriteBatch;
delete<T>(documentRef: firestore.DocumentReference<T>, precondition?: firestore.Precondition): WriteBatch;
set<T>(documentRef: firestore.DocumentReference<T>, data: Partial<T>, options: firestore.SetOptions): WriteBatch;
set<T>(documentRef: firestore.DocumentReference<T>, data: T): WriteBatch;
set<T>(documentRef: firestore.DocumentReference<T>, data: T | Partial<T>, options?: firestore.SetOptions): WriteBatch;
/**
* Write to the document referred to by the provided
* [DocumentReference]{@link DocumentReference}.
* If the document does not exist yet, it will be created. If you pass
* [SetOptions]{@link SetOptions}., the provided data can be merged
* into the existing document.
*
* @param {DocumentReference} documentRef A reference to the document to be
* set.
* @param {T} data The object to serialize as the document.
* @param {SetOptions=} options An object to configure the set behavior.
* @param {boolean=} options.merge - If true, set() merges the values
* specified in its data argument. Fields omitted from this set() call
* remain untouched.
* @param {Array.<string|FieldPath>=} options.mergeFields - If provided,
* set() only replaces the specified field paths. Any field path that is not
* specified is ignored and remains untouched.
* @returns {WriteBatch} This WriteBatch instance. Used for chaining
* method calls.
*
* @example
* let writeBatch = firestore.batch();
* let documentRef = firestore.doc('col/doc');
*
* writeBatch.set(documentRef, {foo: 'bar'});
*
* writeBatch.commit().then(() => {
* console.log('Successfully executed batch.');
* });
*/
set<T>(documentRef: DocumentReference<T>, data: T, options?: SetOptions): WriteBatch;
/**
* Update fields of the document referred to by the provided

@@ -225,5 +195,5 @@ * [DocumentReference]{@link DocumentReference}. If the document

*/
update<T = DocumentData>(documentRef: DocumentReference<T>, dataOrField: UpdateData | string | FieldPath, ...preconditionOrValues: Array<{
lastUpdateTime?: Timestamp;
} | unknown | string | FieldPath>): WriteBatch;
update<T = firestore.DocumentData>(documentRef: firestore.DocumentReference<T>, dataOrField: firestore.UpdateData | string | firestore.FieldPath, ...preconditionOrValues: Array<{
lastUpdateTime?: firestore.Timestamp;
} | unknown | string | firestore.FieldPath>): WriteBatch;
/**

@@ -267,3 +237,3 @@ * Atomically commits all pending operations to the database and verifies all

*/
commit_(commitOptions?: {
_commit(commitOptions?: {
transactionId?: Uint8Array;

@@ -273,10 +243,2 @@ requestTag?: string;

/**
* Determines whether we should issue a transactional commit. On GCF, this
* happens after two minutes of idleness.
*
* @private
* @returns Whether to use a transaction.
*/
private _shouldCreateTransaction;
/**
* Resets the WriteBatch and dequeues all pending operations.

@@ -283,0 +245,0 @@ * @private

@@ -27,8 +27,2 @@ "use strict";

const google_gax_1 = require("google-gax");
/*!
* Google Cloud Functions terminates idle connections after two minutes. After
* longer periods of idleness, we issue transactional commits to allow for
* retries.
*/
const GCF_IDLE_TIMEOUT_MS = 110 * 1000;
/**

@@ -155,20 +149,18 @@ * A WriteResult wraps the write time set by the Firestore servers on sets(),

create(documentRef, data) {
reference_1.validateDocumentReference('documentRef', documentRef);
const firestoreData = documentRef._converter.toFirestore(data);
const ref = reference_1.validateDocumentReference('documentRef', documentRef);
const firestoreData = ref._converter.toFirestore(data);
validateDocumentData('data', firestoreData,
/* allowDeletes= */ false, this._allowUndefined);
this.verifyNotCommitted();
const transform = document_1.DocumentTransform.fromObject(documentRef, firestoreData);
const transform = document_1.DocumentTransform.fromObject(ref, firestoreData);
transform.validate();
const precondition = new document_1.Precondition({ exists: false });
const op = () => {
const document = document_1.DocumentSnapshot.fromObject(documentRef, firestoreData);
const write = document.toProto();
const document = document_1.DocumentSnapshot.fromObject(ref, firestoreData);
const write = document.toWriteProto();
if (!transform.isEmpty) {
write.updateTransforms = transform.toProto(this._serializer);
}
return {
write,
precondition: precondition.toProto(),
};
write.currentDocument = precondition.toProto();
return write;
};

@@ -202,3 +194,3 @@ this._ops.push(op);

delete(documentRef, precondition) {
reference_1.validateDocumentReference('documentRef', documentRef);
const ref = reference_1.validateDocumentReference('documentRef', documentRef);
validateDeletePrecondition('precondition', precondition, { optional: true });

@@ -208,8 +200,7 @@ this.verifyNotCommitted();

const op = () => {
return {
write: {
delete: documentRef.formattedName,
},
precondition: conditions.toProto(),
};
const write = { delete: ref.formattedName };
if (!conditions.isEmpty) {
write.currentDocument = conditions.toProto();
}
return write;
};

@@ -221,10 +212,9 @@ this._ops.push(op);

* Write to the document referred to by the provided
* [DocumentReference]{@link DocumentReference}.
* If the document does not exist yet, it will be created. If you pass
* [SetOptions]{@link SetOptions}., the provided data can be merged
* into the existing document.
* [DocumentReference]{@link DocumentReference}. If the document does not
* exist yet, it will be created. If you pass [SetOptions]{@link SetOptions},
* the provided data can be merged into the existing document.
*
* @param {DocumentReference} documentRef A reference to the document to be
* set.
* @param {T} data The object to serialize as the document.
* @param {T|Partial<T>} data The object to serialize as the document.
* @param {SetOptions=} options An object to configure the set behavior.

@@ -254,4 +244,13 @@ * @param {boolean=} options.merge - If true, set() merges the values

const mergePaths = options && options.mergeFields;
reference_1.validateDocumentReference('documentRef', documentRef);
let firestoreData = documentRef._converter.toFirestore(data);
const ref = reference_1.validateDocumentReference('documentRef', documentRef);
let firestoreData;
if (mergeLeaves || mergePaths) {
// Cast to any in order to satisfy the union type constraint on
// toFirestore().
// eslint-disable-next-line @typescript-eslint/no-explicit-any
firestoreData = ref._converter.toFirestore(data, options);
}
else {
firestoreData = ref._converter.toFirestore(data);
}
validateDocumentData('data', firestoreData,

@@ -275,3 +274,3 @@ /* allowDeletes= */ !!(mergePaths || mergeLeaves), this._allowUndefined);

}
const write = document.toProto();
const write = document.toWriteProto();
if (!transform.isEmpty) {

@@ -283,5 +282,3 @@ write.updateTransforms = transform.toProto(this._serializer);

}
return {
write,
};
return write;
};

@@ -328,2 +325,3 @@ this._ops.push(op);

update(documentRef, dataOrField, ...preconditionOrValues) {
// eslint-disable-next-line prefer-rest-params
validate_1.validateMinNumberOfArguments('WriteBatch.update', arguments, 2);

@@ -339,10 +337,14 @@ reference_1.validateDocumentReference('documentRef', documentRef);

if (usesVarargs) {
const argumentOffset = 1; // Respect 'documentRef' in the error message
const fieldOrValues = [dataOrField, ...preconditionOrValues];
try {
for (let i = 1; i < arguments.length; i += 2) {
if (i === arguments.length - 1) {
validateUpdatePrecondition(i, arguments[i]);
precondition = new document_1.Precondition(arguments[i]);
for (let i = 0; i < fieldOrValues.length; i += 2) {
if (i === fieldOrValues.length - 1) {
const maybePrecondition = fieldOrValues[i];
validateUpdatePrecondition(i + argumentOffset, maybePrecondition);
precondition = new document_1.Precondition(maybePrecondition);
}
else {
path_1.validateFieldPath(i, arguments[i]);
const maybeFieldPath = fieldOrValues[i];
path_1.validateFieldPath(i + argumentOffset, maybeFieldPath);
// Unlike the `validateMinNumberOfArguments` invocation above, this

@@ -352,6 +354,6 @@ // validation can be triggered both from `WriteBatch.update()` and

// qualified API name in the error message.
validate_1.validateMinNumberOfArguments('update', arguments, i + 1);
const fieldPath = path_1.FieldPath.fromArgument(arguments[i]);
validateFieldValue(i, arguments[i + 1], this._allowUndefined, fieldPath);
updateMap.set(fieldPath, arguments[i + 1]);
validate_1.validateMinNumberOfArguments('update', fieldOrValues, i + 1);
const fieldPath = path_1.FieldPath.fromArgument(maybeFieldPath);
validateFieldValue(i + argumentOffset, fieldOrValues[i + 1], this._allowUndefined, fieldPath);
updateMap.set(fieldPath, fieldOrValues[i + 1]);
}

@@ -370,2 +372,3 @@ }

validateUpdateMap('dataOrField', dataOrField, this._allowUndefined);
// eslint-disable-next-line prefer-rest-params
validate_1.validateMaxNumberOfArguments('update', arguments, 3);

@@ -395,3 +398,3 @@ const data = dataOrField;

const document = document_1.DocumentSnapshot.fromUpdateMap(documentRef, updateMap);
const write = document.toProto();
const write = document.toWriteProto();
write.updateMask = documentMask.toProto();

@@ -401,6 +404,4 @@ if (!transform.isEmpty) {

}
return {
write,
precondition: precondition.toProto(),
};
write.currentDocument = precondition.toProto();
return write;
};

@@ -430,3 +431,3 @@ this._ops.push(op);

const stack = Error().stack;
return this.commit_().catch(err => {
return this._commit().catch(err => {
throw util_1.wrapError(err, stack);

@@ -449,10 +450,6 @@ });

const database = this._firestore.formattedName;
const request = { database, writes: [] };
const writes = this._ops.map(op => op());
for (const req of writes) {
if (req.precondition) {
req.write.currentDocument = req.precondition;
}
request.writes.push(req.write);
}
const request = {
database,
writes: this._ops.map(op => op()),
};
const retryCodes = [google_gax_1.Status.ABORTED, ...util_1.getRetryCodes('commit')];

@@ -464,3 +461,10 @@ const response = await this._firestore.request('batchWrite', request, tag, retryCodes);

error.code = status.code;
return new BatchWriteResult(result.updateTime ? timestamp_1.Timestamp.fromProto(result.updateTime) : null, error);
// Since delete operations currently do not have write times, use a
// sentinel Timestamp value.
// TODO(b/158502664): Use actual delete timestamp.
const DELETE_TIMESTAMP_SENTINEL = timestamp_1.Timestamp.fromMillis(0);
const updateTime = error.code === google_gax_1.Status.OK
? timestamp_1.Timestamp.fromProto(result.updateTime || DELETE_TIMESTAMP_SENTINEL)
: null;
return new BatchWriteResult(updateTime, error);
});

@@ -478,3 +482,3 @@ }

*/
async commit_(commitOptions) {
async _commit(commitOptions) {
// Note: We don't call `verifyNotCommitted()` to allow for retries.

@@ -485,21 +489,10 @@ this._committed = true;

const database = this._firestore.formattedName;
// On GCF, we periodically force transactional commits to allow for
// request retries in case GCF closes our backend connection.
const explicitTransaction = commitOptions && commitOptions.transactionId;
if (!explicitTransaction && this._shouldCreateTransaction()) {
logger_1.logger('WriteBatch.commit', tag, 'Using transaction for commit');
return this._firestore
.request('beginTransaction', { database }, tag)
.then(resp => {
return this.commit_({ transactionId: resp.transaction });
});
const request = {
database,
writes: this._ops.map(op => op()),
};
if (commitOptions === null || commitOptions === void 0 ? void 0 : commitOptions.transactionId) {
request.transaction = commitOptions.transactionId;
}
const request = { database, writes: [] };
const writes = this._ops.map(op => op());
for (const req of writes) {
if (req.precondition) {
req.write.currentDocument = req.precondition;
}
request.writes.push(req.write);
}
logger_1.logger('WriteBatch.commit', tag, 'Sending %d writes', request.writes.length);

@@ -519,19 +512,2 @@ let retryCodes;

/**
* Determines whether we should issue a transactional commit. On GCF, this
* happens after two minutes of idleness.
*
* @private
* @returns Whether to use a transaction.
*/
_shouldCreateTransaction() {
if (!this._firestore._preferTransactions) {
return false;
}
if (this._firestore._lastSuccessfulRequest) {
const now = new Date().getTime();
return now - this._firestore._lastSuccessfulRequest > GCF_IDLE_TIMEOUT_MS;
}
return true;
}
/**
* Resets the WriteBatch and dequeues all pending operations.

@@ -538,0 +514,0 @@ * @private

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

## [4.0.0](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.6...v4.0.0) (2020-06-24)
### ⚠ BREAKING CHANGES
* drop Node 8 support (#1006)
* `FirestoreDataConverter.fromFirestore()` is now called with a `QueryDocumentSnapshot` instead of `DocumentData` (#965)
### Features
* add support for serialization to BigInt `(via settings({useBigInt: true})` (#1016)
* add support for set() with SetOptions when using `FirestoreDataConverter` (#1087)
* retry CommitRequests that fail with UNAVAILABLE (#1235)
### Bug Fix
- remove fallback code that periodically invoked CommitRequests inside Transactions on GCF (#1112)
- fixes an error that prevented Firestore from connecting to the Emulator if multiple versions of `@grpc/grpc-js` are installed (#1233)
### [3.8.6](https://www.github.com/googleapis/nodejs-firestore/compare/v3.8.5...v3.8.6) (2020-06-19)

@@ -9,0 +28,0 @@

{
"name": "@google-cloud/firestore",
"description": "Firestore Client Library for Node.js",
"version": "3.8.6",
"version": "4.0.0",
"license": "Apache-2.0",
"author": "Google Inc.",
"engines": {
"node": "^8.13.0 || >=10.10.0"
"node": ">=10.10.0"
},

@@ -53,7 +53,5 @@ "repository": "googleapis/nodejs-firestore",

"dependencies": {
"deep-equal": "^2.0.0",
"fast-deep-equal": "^3.1.1",
"functional-red-black-tree": "^1.0.1",
"google-gax": "^1.15.3",
"readable-stream": "^3.4.0",
"through2": "^3.0.0"
"google-gax": "^2.2.0"
},

@@ -68,2 +66,3 @@ "devDependencies": {

"@types/node": "^12.12.17",
"@types/sinon": "^9.0.0",
"@types/through2": "^2.0.34",

@@ -76,6 +75,7 @@ "c8": "^7.0.0",

"extend": "^3.0.2",
"gts": "^1.1.2",
"gts": "^2.0.0-alpha.9",
"jsdoc": "^3.6.2",
"jsdoc-fresh": "^1.0.2",
"jsdoc-region-tag": "^1.0.2",
"length-prefixed-json-stream": "^1.0.1",
"linkinator": "^2.0.0",

@@ -85,5 +85,7 @@ "mocha": "^7.0.0",

"proxyquire": "^2.1.3",
"sinon": "^9.0.2",
"ts-node": "^8.5.4",
"typescript": "3.8.3"
"typescript": "3.8.3",
"through2": "^3.0.0"
}
}

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

// Read the document.
let doc = await document.get();
const doc = await document.get();
console.log('Read the document');

@@ -109,2 +109,3 @@

| --------------------------- | --------------------------------- | ------ |
| Limit-to-last-query | [source code](https://github.com/googleapis/nodejs-firestore/blob/master/samples/limit-to-last-query.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-firestore&page=editor&open_in_editor=samples/limit-to-last-query.js,samples/README.md) |
| Quickstart | [source code](https://github.com/googleapis/nodejs-firestore/blob/master/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-firestore&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |

@@ -111,0 +112,0 @@ | Solution-counters | [source code](https://github.com/googleapis/nodejs-firestore/blob/master/samples/solution-counters.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-firestore&page=editor&open_in_editor=samples/solution-counters.js,samples/README.md) |

@@ -19,3 +19,5 @@ /**

// tslint:disable
// We deliberately use `any` in the external API to not impose type-checking
// on end users.
/* eslint-disable @typescript-eslint/no-explicit-any */

@@ -40,8 +42,8 @@ // Declare a global (ambient) namespace

* Sets or disables the log function for all active Firestore instances.
*
*
* @param logger A log function that takes a message (such as `console.log`) or
* `null` to turn off logging.
*/
function setLogFunction(logger: ((msg:string) => void) | null) : void;
function setLogFunction(logger: ((msg: string) => void) | null): void;
/**

@@ -68,4 +70,5 @@ * Converter used by `withConverter()` to transform user objects of type T

* fromFirestore(
* data: FirebaseFirestore.DocumentData
* snapshot: FirebaseFirestore.QueryDocumentSnapshot
* ): Post {
* const data = snapshot.data();
* return new Post(data.title, data.author);

@@ -90,5 +93,7 @@ * }

* into a plain Javascript object (suitable for writing directly to the
* Firestore database).
* Firestore database). To use set() with `merge` and `mergeFields`,
* toFirestore() must be defined with `Partial<T>`.
*/
toFirestore(modelObject: T): DocumentData;
toFirestore(modelObject: Partial<T>, options: SetOptions): DocumentData;

@@ -99,3 +104,3 @@ /**

*/
fromFirestore(data: DocumentData): T;
fromFirestore(snapshot: QueryDocumentSnapshot): T;
}

@@ -139,3 +144,3 @@

*/
credentials?: {client_email?:string, private_key?:string};
credentials?: {client_email?: string; private_key?: string};

@@ -154,2 +159,10 @@ /** Whether to use SSL when connecting. */

/**
* Whether to use `BigInt` for integer types when deserializing Firestore
* Documents. Regardless of magnitude, all integer values are returned as
* `BigInt` to match the precision of the Firestore backend. Floating point
* numbers continue to use JavaScript's `number` type.
*/
useBigInt?: boolean;
/**
* Whether to skip nested properties that are set to `undefined` during

@@ -161,3 +174,3 @@ * object serialization. If set to `true`, these properties are skipped

ignoreUndefinedProperties?: boolean;
[key: string]: any; // Accept other properties, such as GRPC settings.

@@ -234,4 +247,7 @@ }

*/
getAll(...documentRefsOrReadOptions: Array<DocumentReference<DocumentData> | ReadOptions>):
Promise<Array<DocumentSnapshot<DocumentData>>>;
getAll(
...documentRefsOrReadOptions: Array<
DocumentReference<DocumentData> | ReadOptions
>
): Promise<Array<DocumentSnapshot<DocumentData>>>;

@@ -251,3 +267,3 @@ /**

*/
listCollections() : Promise<Array<CollectionReference<DocumentData>>>;
listCollections(): Promise<Array<CollectionReference<DocumentData>>>;

@@ -274,4 +290,4 @@ /**

runTransaction<T>(
updateFunction: (transaction: Transaction) => Promise<T>,
transactionOptions?:{maxAttempts?: number}
updateFunction: (transaction: Transaction) => Promise<T>,
transactionOptions?: {maxAttempts?: number}
): Promise<T>;

@@ -355,4 +371,5 @@

*/
getAll<T>(...documentRefsOrReadOptions: Array<DocumentReference|ReadOptions>):
Promise<Array<DocumentSnapshot<T>>>;
getAll<T>(
...documentRefsOrReadOptions: Array<DocumentReference<T> | ReadOptions>
): Promise<Array<DocumentSnapshot<T>>>;

@@ -380,4 +397,8 @@ /**

*/
set<T>(documentRef: DocumentReference<T>, data: T,
options?: SetOptions): Transaction;
set<T>(
documentRef: DocumentReference<T>,
data: Partial<T>,
options: SetOptions
): Transaction;
set<T>(documentRef: DocumentReference<T>, data: T): Transaction;

@@ -398,4 +419,7 @@ /**

*/
update(documentRef: DocumentReference<any>, data: UpdateData,
precondition?: Precondition): Transaction;
update(
documentRef: DocumentReference<any>,
data: UpdateData,
precondition?: Precondition
): Transaction;

@@ -421,4 +445,8 @@ /**

*/
update(documentRef: DocumentReference<any>, field: string|FieldPath, value:any,
...fieldsOrPrecondition: any[]): Transaction;
update(
documentRef: DocumentReference<any>,
field: string | FieldPath,
value: any,
...fieldsOrPrecondition: any[]
): Transaction;

@@ -432,4 +460,6 @@ /**

*/
delete(documentRef: DocumentReference<any>,
precondition?: Precondition): Transaction;
delete(
documentRef: DocumentReference<any>,
precondition?: Precondition
): Transaction;
}

@@ -472,4 +502,8 @@

*/
set<T>(documentRef: DocumentReference<T>, data: T,
options?: SetOptions): WriteBatch;
set<T>(
documentRef: DocumentReference<T>,
data: Partial<T>,
options: SetOptions
): WriteBatch;
set<T>(documentRef: DocumentReference<T>, data: T): WriteBatch;

@@ -490,4 +524,7 @@ /**

*/
update(documentRef: DocumentReference<any>, data: UpdateData,
precondition?: Precondition): WriteBatch;
update(
documentRef: DocumentReference<any>,
data: UpdateData,
precondition?: Precondition
): WriteBatch;

@@ -512,4 +549,8 @@ /**

*/
update(documentRef: DocumentReference<any>, field: string|FieldPath, value:any,
...fieldsOrPrecondition: any[]): WriteBatch;
update(
documentRef: DocumentReference<any>,
field: string | FieldPath,
value: any,
...fieldsOrPrecondition: any[]
): WriteBatch;

@@ -523,4 +564,6 @@ /**

*/
delete(documentRef: DocumentReference<any>,
precondition?: Precondition): WriteBatch;
delete(
documentRef: DocumentReference<any>,
precondition?: Precondition
): WriteBatch;

@@ -571,3 +614,3 @@ /**

*/
readonly mergeFields?: (string|FieldPath)[];
readonly mergeFields?: (string | FieldPath)[];
}

@@ -589,3 +632,3 @@

*/
readonly fieldMask?: (string|FieldPath)[];
readonly fieldMask?: (string | FieldPath)[];
}

@@ -657,3 +700,3 @@

*/
listCollections() : Promise<Array<CollectionReference<DocumentData>>>;
listCollections(): Promise<Array<CollectionReference<DocumentData>>>;

@@ -678,3 +721,4 @@ /**

*/
set(data: T, options?: SetOptions): Promise<WriteResult>;
set(data: Partial<T>, options: SetOptions): Promise<WriteResult>;
set(data: T): Promise<WriteResult>;

@@ -712,4 +756,7 @@ /**

*/
update(field: string|FieldPath, value:any,
...moreFieldsOrPrecondition: any[]): Promise<WriteResult>;
update(
field: string | FieldPath,
value: any,
...moreFieldsOrPrecondition: any[]
): Promise<WriteResult>;

@@ -722,3 +769,3 @@ /**

*/
delete(precondition?:Precondition): Promise<WriteResult>;
delete(precondition?: Precondition): Promise<WriteResult>;

@@ -743,4 +790,6 @@ /**

*/
onSnapshot(onNext: (snapshot: DocumentSnapshot<T>) => void,
onError?: (error: Error) => void): () => void;
onSnapshot(
onNext: (snapshot: DocumentSnapshot<T>) => void,
onError?: (error: Error) => void
): () => void;

@@ -825,3 +874,3 @@ /**

*/
get(fieldPath: string|FieldPath): any;
get(fieldPath: string | FieldPath): any;

@@ -849,3 +898,5 @@ /**

*/
export class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<T> {
export class QueryDocumentSnapshot<T = DocumentData> extends DocumentSnapshot<
T
> {
private constructor();

@@ -881,7 +932,14 @@

* Filter conditions in a `Query.where()` clause are specified using the
* strings '<', '<=', '==', '>=', '>', 'array-contains', 'in', and
* strings '<', '<=', '==', '>=', '>', 'array-contains', 'in', and
* 'array-contains-any'.
*/
export type WhereFilterOp = '<' | '<=' | '==' | '>=' | '>' | 'array-contains' |
'in' | 'array-contains-any';
export type WhereFilterOp =
| '<'
| '<='
| '=='
| '>='
| '>'
| 'array-contains'
| 'in'
| 'array-contains-any';

@@ -914,3 +972,7 @@ /**

*/
where(fieldPath: string|FieldPath, opStr: WhereFilterOp, value: any): Query<T>;
where(
fieldPath: string | FieldPath,
opStr: WhereFilterOp,
value: any
): Query<T>;

@@ -930,7 +992,8 @@ /**

orderBy(
fieldPath: string|FieldPath, directionStr?: OrderByDirection
fieldPath: string | FieldPath,
directionStr?: OrderByDirection
): Query<T>;
/**
* Creates and returns a new Query that only returns the first matching
* Creates and returns a new Query that only returns the first matching
* documents.

@@ -945,3 +1008,3 @@ *

limit(limit: number): Query<T>;
/**

@@ -951,5 +1014,5 @@ * Creates and returns a new Query that only returns the last matching

*
* You must specify at least one orderBy clause for limitToLast queries,
* You must specify at least one orderBy clause for limitToLast queries,
* otherwise an exception will be thrown during execution.
*
*
* Results for limitToLast queries cannot be streamed via the `stream()`

@@ -1103,4 +1166,6 @@ * API.

*/
onSnapshot(onNext: (snapshot: QuerySnapshot<T>) => void,
onError?: (error: Error) => void) : () => void;
onSnapshot(
onNext: (snapshot: QuerySnapshot<T>) => void,
onError?: (error: Error) => void
): () => void;

@@ -1115,3 +1180,3 @@ /**

/**
/**
* Applies a custom data converter to this Query, allowing you to use your

@@ -1171,3 +1236,4 @@ * own custom model objects with Firestore. When you call get() on the

forEach(
callback: (result: QueryDocumentSnapshot<T>) => void, thisArg?: any
callback: (result: QueryDocumentSnapshot<T>) => void,
thisArg?: any
): void;

@@ -1517,4 +1583,5 @@

* Firestore v1beta1 RPCs.
* @deprecated Use v1 instead.
*/
export const v1beta1 : any;
export const v1beta1: any;

@@ -1525,3 +1592,3 @@ /**

*/
export const v1: {FirestoreClient: any, FirestoreAdminClient: any};
export const v1: {FirestoreClient: any; FirestoreAdminClient: any};

@@ -1548,3 +1615,3 @@ /**

DATA_LOSS = 15,
UNAUTHENTICATED = 16
UNAUTHENTICATED = 16,
}

@@ -1551,0 +1618,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 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 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 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 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 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 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